1. /proc/kallsyms列出了linux內(nèi)核導(dǎo)出的所有符號及對應(yīng)的地址。
基本格式是: 邏輯地址?? 標識? 符號(內(nèi)核導(dǎo)出的符號),如00100000 A phys_startup_32
標識分為A、T、t、W、R、D等,分別意義如下:
c0100000 A _text??????????????注:表示內(nèi)核代碼第一個字節(jié)的地址
c02fa1af A _etext??????注:內(nèi)核代碼結(jié)束的位置,之后為內(nèi)核初始化的數(shù)據(jù)
c03e1b40 A _edata???????注:內(nèi)核初始化數(shù)據(jù)結(jié)束,之后為未初始化數(shù)據(jù)
c043a068 A _end???????????????????????? 注:內(nèi)核未初始化數(shù)據(jù)結(jié)束
標識說明:
小寫字母表示局部; 大寫字母表示全局(外部).
A
The symbol's value is absolute, and will not be changed by further linking.
B
The symbol is in the uninitialized data section (known as BSS).
C
The symbol is common. Common symbols are uninitialized data. When linking, multiple common symbols may appear with the same name. If the symbol is defined anywhere, the common symbols are treated as undefined references. For more details on common symbols, see the discussion of -warn-common in Linker options.
D
The symbol is in the initialized data section.
G
The symbol is in an initialized data section for small objects. Some object file formats permit more efficient access to small data objects, such as a global int variable as opposed to a large global array.
I
The symbol is an indirect reference to another symbol. This is a GNU extension to the a.out object file format which is rarely used.
N
The symbol is a debugging symbol.
R
The symbol is in a read only data section.
S
The symbol is in an uninitialized data section for small objects.
T
The symbol is in the text (code) section.
U
The symbol is undefined.
V
The symbol is a weak object. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error.
W
The symbol is a weak symbol that has not been specifically tagged as a weak object symbol. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error.
-
The symbol is a stabs symbol in an a.out object file. In this case, the next values printed are the stabs other field, the stabs desc field, and the stab type. Stabs symbols are used to hold debugging information. For more information, see Stabs.
?
The symbol type is unknown, or object file format specific.?
??
2. 如果沒有/proc/kallsyms,可以借助編譯內(nèi)核是生成的system.map(在/usr/src/linux中,使用nm /boot/vmlinux-2.4.7-10 > System.map)中的符號,然后使用unsigned long kallsyms_lookup_name(const char *)尋找指定符號的邏輯地址。頭文件好像是<linux/kallsyms.h>