Go命令行—nm

Nm列出了由目标文件,存档或可执行文件定义或使用过的符号。

go tool nm [options] file...

默认输出样式为:每个符号占一行,三个空格分隔的字段分别是地址(十六进制),类型(一个字符)和符号的名称。类型包括:

T	text (code) segment symbol
t	static text segment symbol
R	read-only data segment symbol
r	static read-only data segment symbol
D	data segment symbol
d	static data segment symbol
B	bss segment symbol
b	static bss segment symbol
C	constant address
U	referenced but undefined symbol

遵循建立的约定,未定义的符号(类型U)的地址被省略。

控制打印输出的选项有:

-n
	an alias for -sort address (numeric),
	for compatibility with other nm commands
-size
	print symbol size in decimal between address and type
-sort {address,name,none,size}
	sort output in the given order (default name)
	size orders from largest to smallest
-type
	print symbol type after name