xref: /OK3568_Linux_fs/kernel/scripts/mksysmap (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/sh -x
2*4882a593Smuzhiyun# Based on the vmlinux file create the System.map file
3*4882a593Smuzhiyun# System.map is used by module-init tools and some debugging
4*4882a593Smuzhiyun# tools to retrieve the actual addresses of symbols in the kernel.
5*4882a593Smuzhiyun#
6*4882a593Smuzhiyun# Usage
7*4882a593Smuzhiyun# mksysmap vmlinux System.map
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun#####
11*4882a593Smuzhiyun# Generate System.map (actual filename passed as second argument)
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun# $NM produces the following output:
14*4882a593Smuzhiyun# f0081e80 T alloc_vfsmnt
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun#   The second row specify the type of the symbol:
17*4882a593Smuzhiyun#   A = Absolute
18*4882a593Smuzhiyun#   B = Uninitialised data (.bss)
19*4882a593Smuzhiyun#   C = Common symbol
20*4882a593Smuzhiyun#   D = Initialised data
21*4882a593Smuzhiyun#   G = Initialised data for small objects
22*4882a593Smuzhiyun#   I = Indirect reference to another symbol
23*4882a593Smuzhiyun#   N = Debugging symbol
24*4882a593Smuzhiyun#   R = Read only
25*4882a593Smuzhiyun#   S = Uninitialised data for small objects
26*4882a593Smuzhiyun#   T = Text code symbol
27*4882a593Smuzhiyun#   U = Undefined symbol
28*4882a593Smuzhiyun#   V = Weak symbol
29*4882a593Smuzhiyun#   W = Weak symbol
30*4882a593Smuzhiyun#   Corresponding small letters are local symbols
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun# For System.map filter away:
33*4882a593Smuzhiyun#   a - local absolute symbols
34*4882a593Smuzhiyun#   U - undefined global symbols
35*4882a593Smuzhiyun#   N - debugging symbols
36*4882a593Smuzhiyun#   w - local weak symbols
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun# readprofile starts reading symbols when _stext is found, and
39*4882a593Smuzhiyun# continue until it finds a symbol which is not either of 'T', 't',
40*4882a593Smuzhiyun# 'W' or 'w'. __crc_ are 'A' and placed in the middle
41*4882a593Smuzhiyun# so we just ignore them to let readprofile continue to work.
42*4882a593Smuzhiyun# (At least sparc64 has __crc_ in the middle).
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)\|\( L0\)' > $2
45