Linux nm 命令使用及符号含义

1 nm 命令介绍

NAME
       nm - list symbols from object files

SYNOPSIS
       nm [-A|-o|--print-file-name] [-a|--debug-syms]
          [-B|--format=bsd] [-C|--demangle[=style]]
          [-D|--dynamic] [-fformat|--format=format]
          [-g|--extern-only] [-h|--help]
          [-l|--line-numbers] [-n|-v|--numeric-sort]
          [-P|--portability] [-p|--no-sort]
          [-r|--reverse-sort] [-S|--print-size]
          [-s|--print-armap] [-t radix|--radix=radix]
          [-u|--undefined-only] [-V|--version]
          [-X 32_64] [--defined-only] [--no-demangle]
          [--plugin name] [--size-sort] [--special-syms]
          [--synthetic] [--target=bfdname]
          [objfile...]

DESCRIPTION
       GNU nm lists the symbols from object files objfile....  If no object
       files are listed as arguments, nm assumes the file a.out.

       For each symbol, nm shows:
        # ... run man nm for detials.

简单说的话,就是可以帮你列举出该目标中定义的符合要求的符号。要求可以很多,主要通过参数实现:外部引入的、内部定义的、动态的... 也可以添加参数使nm同时打印行号、文件名等相关信息。

2 nm 结果含义

nm 将找到的符号值使用十六进制缺省表示,并在函数前添加其类型,类型主要有:

ValueDescripitionNote
AThe symbol's value is absolute, and will not be changed by further linking.符号绝对,链接过程不会改变
B/bThe symbol is in the uninitialized data section (known as BSS).非初始化符号
CThe symbol is common.公有符号,链接时会被同名符号覆盖
D/dThe symbol is in the initialized data section.初始化符号
G/gThe symbol is in an initialized data section for small objects.初始化符号,面向小数据访问优化
IThe symbol is an indirect reference to another symbol.其它符号的间接引用
NThe symbol is a debugging symbol.调试符号
PThe symbols is in a stack unwind section.栈区符号(清空)
R/rThe symbol is in a read only data section.符号只读
S/sThe symbol is in an uninitialized data section for small objects.非初始化符号,面向小数据访问优化
T/tThe symbol is in the text (code) section.代码区符号
UThe symbol is undefined.未定义或在外部定义的符号
uThe symbol is a unique global symbol.全局唯一,GNU保留符
V/vThe symbol is a weak object.弱定义符(详见C++强弱符号定义)
W/wThe 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也不认识的符号

 


  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值