nm 将找到的符号值使用十六进制缺省表示,并在函数前添加其类型,类型主要有:
Value | Descripition | Note |
---|---|---|
A | The symbol's value is absolute, and will not be changed by further linking. | 符号绝对,链接过程不会改变 |
B/b | The symbol is in the uninitialized data section (known as BSS). | 非初始化符号 |
C | The symbol is common. | 公有符号,链接时会被同名符号覆盖 |
D/d | The symbol is in the initialized data section. | 初始化符号 |
G/g | The symbol is in an initialized data section for small objects. | 初始化符号,面向小数据访问优化 |
I | The symbol is an indirect reference to another symbol. | 其它符号的间接引用 |
N | The symbol is a debugging symbol. | 调试符号 |
P | The symbols is in a stack unwind section. | 栈区符号(清空) |
R/r | The symbol is in a read only data section. | 符号只读 |
S/s | The symbol is in an uninitialized data section for small objects. | 非初始化符号,面向小数据访问优化 |
T/t | The symbol is in the text (code) section. | 代码区符号 |
U | The symbol is undefined. | 未定义或在外部定义的符号 |
u | The symbol is a unique global symbol. | 全局唯一,GNU保留符 |
V/v | The symbol is a weak object. | 弱定义符(详见C++强弱符号定义) |
W/w | The symbol is a weak symbol that has not been specifically tagged as a weak object symbol. | emm...绕口令符号 |
- | The symbol is a stabs symbol in an a.out object file. | stabs格式符号 |
? | The symbol type is unknown, or object file format specific. | NM也不认识的符号 |
注意几点:
- -C 总是适用于c++编译出来的对象文件。还记得c++中有重载么?为了区分重载函数,c++编译器会将函数返回值/参数等信息附加到函数名称中去形成一个mangle过的符号,那用这个选项列出符号的时候,做一个逆操作,输出那些原始的、我们可理解的符号名称。
- 使用 -l 时,必须保证你的对象文件中带有符号调式信息,这一般要求你在编译的时候指定一个 -g 选项,见 Linux:Gcc。
- 使用nm前,最好先用Linux:File查看对象文件所属处理器架构,然后再用相应交叉版本的nm工具。