Chapter 4 107
Linker Tools
Viewing Symbols in an Object file with nm(1)
Viewing Symbols in an Object file with
nm(1)
The nm(1) command displays the symbol table of each specified object.
file can be a relocatable object file or an executable object file, or an
archive of relocatable or executable object files.
nm provides three general output formats: the default (neither –p nor –P
specified), –p, and –P. See the nm(1) man page for a detailed description
of the output formats.
To
Use This
Option
Prefix each output line with the name of the object file or archive, file.
Equivalent to –r.
–A
64-bit mode ELF files only: Demangle C++ names before printing them. –C
Display the value and size of a symbol in decimal. This is the default for the
default format or the –p format. Equivalent to -t d.
–d
Display only external and static symbols. This option is ignored (see –f). –e
Display full output. This option is in force by default. –f
Display only external (global) symbol information. –g
Do not display the output header data. –h
Distinguish between weak and global symbols by appending * to the key
letter of weak symbols. Only takes effect with -p and/or -P.
–l
Sort symbols by name, in ascending collation order, before they are printed.
This is the default. To turn off this option, use -N.
–n
Display symbols in the order in which they appear in the symbol table. –N
Display the value and size of a symbol in octal. Equivalent to -t o. –o