18c2ecf20Sopenharmony_ci#!/bin/sh -x 28c2ecf20Sopenharmony_ci# Based on the vmlinux file create the System.map file 38c2ecf20Sopenharmony_ci# System.map is used by module-init tools and some debugging 48c2ecf20Sopenharmony_ci# tools to retrieve the actual addresses of symbols in the kernel. 58c2ecf20Sopenharmony_ci# 68c2ecf20Sopenharmony_ci# Usage 78c2ecf20Sopenharmony_ci# mksysmap vmlinux System.map 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci##### 118c2ecf20Sopenharmony_ci# Generate System.map (actual filename passed as second argument) 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci# $NM produces the following output: 148c2ecf20Sopenharmony_ci# f0081e80 T alloc_vfsmnt 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci# The second row specify the type of the symbol: 178c2ecf20Sopenharmony_ci# A = Absolute 188c2ecf20Sopenharmony_ci# B = Uninitialised data (.bss) 198c2ecf20Sopenharmony_ci# C = Common symbol 208c2ecf20Sopenharmony_ci# D = Initialised data 218c2ecf20Sopenharmony_ci# G = Initialised data for small objects 228c2ecf20Sopenharmony_ci# I = Indirect reference to another symbol 238c2ecf20Sopenharmony_ci# N = Debugging symbol 248c2ecf20Sopenharmony_ci# R = Read only 258c2ecf20Sopenharmony_ci# S = Uninitialised data for small objects 268c2ecf20Sopenharmony_ci# T = Text code symbol 278c2ecf20Sopenharmony_ci# U = Undefined symbol 288c2ecf20Sopenharmony_ci# V = Weak symbol 298c2ecf20Sopenharmony_ci# W = Weak symbol 308c2ecf20Sopenharmony_ci# Corresponding small letters are local symbols 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci# For System.map filter away: 338c2ecf20Sopenharmony_ci# a - local absolute symbols 348c2ecf20Sopenharmony_ci# U - undefined global symbols 358c2ecf20Sopenharmony_ci# N - debugging symbols 368c2ecf20Sopenharmony_ci# w - local weak symbols 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci# readprofile starts reading symbols when _stext is found, and 398c2ecf20Sopenharmony_ci# continue until it finds a symbol which is not either of 'T', 't', 408c2ecf20Sopenharmony_ci# 'W' or 'w'. __crc_ are 'A' and placed in the middle 418c2ecf20Sopenharmony_ci# so we just ignore them to let readprofile continue to work. 428c2ecf20Sopenharmony_ci# (At least sparc64 has __crc_ in the middle). 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)\|\( L0\)' > $2 45