^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1) #!/bin/sh -x
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 2) # Based on the vmlinux file create the System.map file
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) # System.map is used by module-init tools and some debugging
943ffb587cfdf (Adrian Bunk 2006-01-10 00:10:13 +0100 4) # tools to retrieve the actual addresses of symbols in the kernel.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 6) # Usage
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7) # mksysmap vmlinux System.map
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 9)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 10) #####
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11) # Generate System.map (actual filename passed as second argument)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 12)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 13) # $NM produces the following output:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 14) # f0081e80 T alloc_vfsmnt
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 15)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 16) # The second row specify the type of the symbol:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 17) # A = Absolute
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 18) # B = Uninitialised data (.bss)
4fec54203f7b2 (Masatake YAMATO 2012-07-14 01:38:57 +0900 19) # C = Common symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 20) # D = Initialised data
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 21) # G = Initialised data for small objects
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22) # I = Indirect reference to another symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 23) # N = Debugging symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 24) # R = Read only
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 25) # S = Uninitialised data for small objects
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26) # T = Text code symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27) # U = Undefined symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) # V = Weak symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) # W = Weak symbol
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 30) # Corresponding small letters are local symbols
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 31)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 32) # For System.map filter away:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 33) # a - local absolute symbols
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 34) # U - undefined global symbols
aab34ac858230 (Sam Ravnborg 2008-05-19 20:07:58 +0200 35) # N - debugging symbols
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 36) # w - local weak symbols
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 37)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 38) # readprofile starts reading symbols when _stext is found, and
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 39) # continue until it finds a symbol which is not either of 'T', 't',
2ea038917bbdd (Sam Ravnborg 2009-01-14 21:38:20 +0100 40) # 'W' or 'w'. __crc_ are 'A' and placed in the middle
2ea038917bbdd (Sam Ravnborg 2009-01-14 21:38:20 +0100 41) # so we just ignore them to let readprofile continue to work.
2ea038917bbdd (Sam Ravnborg 2009-01-14 21:38:20 +0100 42) # (At least sparc64 has __crc_ in the middle).
2ea038917bbdd (Sam Ravnborg 2009-01-14 21:38:20 +0100 43)
72d24accf02ad (ashimida 2020-06-02 15:45:17 +0800 44) $NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)' > $2