System.map file is a symbol table used by the kernel
背景
System.map文件中包含了符号以及对应的在内存中的地址表信息.
例如
[root@db-172-16-3-150 ~]# less /boot/System.map-$(uname -r)
[root@db-172-16-3-150 ~]# uname -r
2.6.32-358.el6.x86_64
[root@db-172-16-3-150 ~]# less /boot/System.map-2.6.32-358.el6.x86_64
0000000000000000 A VDSO32_PRELINK
0000000000000000 D __per_cpu_start
0000000000000000 D per_cpu__irq_stack_union
0000000000000000 A xen_irq_disable_direct_reloc
0000000000000000 A xen_save_fl_direct_reloc
0000000000000040 A VDSO32_vsyscall_eh_frame_size
... 略
中间的字段代表符号类型信息, 第一个字段是内存地址, 第三个字段是符号名 :
类型如下 :
Some of these types are:
A for absolute.
B or b for uninitialized data section (called BSS).
D or d for initialized data section.
G or g for initialized data section for small objects (global).
i for sections specific to DLLs.
N for debugging symbol.
p for stack unwind section.
R or r for read only data section.
S or s for uninitialzed data section for small objects.
T or t for text (code) section.
U for undefined.
V or v for weak object.
W or w for weak objects which have not been tagged so.
- for stabs symbol in an a.out object file.
? for 'symbol type unknown.'
在其他机器使用stap产生的ko文件时, 如果对方的System.map文件与主文件不一致, 则可能无法使用tapset中的symname()函数通过地址得到符号名.
http://blog.163.com/digoal@126/blog/static/163877040201391451459751/
System.map文件可以在以下两个位置找到.
/usr/src/kernels/`uname -r`/.config
/lib/modules/`uname -r`/build/System.map
[root@db-172-16-3-150 commands]# md5sum /lib/modules/2.6.32-358.el6.x86_64/build/System.map
ef58493777cfca95c66aab2028d771a0 /lib/modules/2.6.32-358.el6.x86_64/build/System.map
[root@db-172-16-3-150 commands]# md5sum /boot/System.map-2.6.32-358.el6.x86_64
ef58493777cfca95c66aab2028d771a0 /boot/System.map-2.6.32-358.el6.x86_64
符号表更多的信息可参考http://en.wikipedia.org/wiki/Symbol_table
[其他]
内核自动产生的make config,
/usr/src/kernels/2.6.32-358.el6.x86_64/.config
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.32-358.el6.x86_64
# Fri Feb 22 00:26:01 2013
#
CONFIG_64BIT=y
# CONFIG_X86_32 is not set
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_GENERIC_CMOS_UPDATE=y
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_HAVE_LATENCYTOP_SUPPORT=y
CONFIG_MMU=y
CONFIG_ZONE_DMA=y
CONFIG_NEED_DMA_MAP_STATE=y
...
参考
1. http://en.wikipedia.org/wiki/System.map
2. http://en.wikipedia.org/wiki/Kernel_oops
3. http://en.wikipedia.org/wiki/Kernel_panic
4. https://sourceware.org/systemtap/SystemTap_Beginners_Guide/useful-systemtap-scripts.html
5. http://en.wikipedia.org/wiki/Symbol_table
6. https://sourceware.org/systemtap/tapsets/API-symname.html
7. /usr/src/kernels/uname -r
/.config
8. /lib/modules/uname -r
/build/System.map