NM(1) NM(1)
nm - print name list of an object file(s)
nm [ -bdefghlnopruvxABCTV ] [ files ]
The nm command prints formatted listings of the symbol tables for each
ELF file specified. A file can be a relocatable or absolute ELF object
file, or it can be an archive.
nm produces different output formats depending on options and the binary
ABI. The differences are an attempt to preserve the operation of scripts
that depend on nm. Anyone desiring consistent operation across different
ABIs should use XPG4 format or Berkeley format.
For old 32-bit-ABI objects the output format by default is the same as
IRIX5.2 and 5.3 (something like AT&T System V Release 3 format).
For new 32-bit-ABI objects the output format by is AT&T System V Release
4 format.
For 64-bit objects the output format is by default in AT&T System V
Release 4 format.
If the environment variable _XPG is defined, nm operates in conformance
with the X/Open XPG4 specifications (called XPG4 mode in this document).
The XPG4 mode format follows the XPG4 standards. In XPG4 mode nm output
looks somewhat like nm -B (Berkeley style) output.
When Using AT&T System V Release 4 format the following information will
be printed for each symbol (an alternative, Berkeley (4.3BSD) format, is
described later in this document):
Index The index of the symbol. (The index appears in brackets.)
Value The value of the symbol is one of the following: a section offset
for defined symbols in a relocatable file; alignment constraints
for symbols whose section index is SHN_COMMON; a virtual address
in executable and dynamic library files.
Size The size in bytes of the associated object.
Type A symbol is one of the following types: NOTYPE (no type was
specified), OBJECT (a data object such as an array or variable),
FUNC (a function or other executable code), SECTION (a section
symbol), or FILE (name of the source file).
Bind The symbol's binding attributes. LOCAL symbols have a scope
limited to the object file containing their definition; GLOBAL
symbols are visible to all object files being combined; and WEAK
symbols are essentially global symbols with a lower precedence
Page 1
NM(1) NM(1)
than GLOBAL.
Other A name scope indicator for (rld()). One of DEFAULT, INTERNAL,
HIDDEN, PROTECTED. (see STO_DEFAULT etc in <sys/elf.h>
Shndx Except for 3 special values, this is the section header table
index in relation to which the symbol is defined. The following
special values exist: ABS indicates the symbol's value will not
change through relocation; COMMON indicates an unallocated block
and the value provides alignment constraints; and UNDEF indicates
an undefined symbol.
Name The name of the symbol.
The nm command supports the options listed below. NOTE: The meaning of
-o depends on whether -A(AT&T) or -B is in effect when -o is seen (the
meaning depends on the relative ordering of the options). Examples:
nm -Bo a.out
nm -oB a.out
In the first example o is given the -B meaning, while in the second, it
is given the -A (default) meaning.
-A Use AT&T System V Release 4 format output. This is the default
for new 32-bit ABI objects and 64bit ABI objects. In XPG4 mode,
-A means write the full pathname of an object on each line.
-B Use Berkeley (4.3BSD) format output. Overrides XPG4 mode.
-b Print the value field in octal.
-C Print decoded C++ names.
-d Print the value field in decimal. This is the default value
field radix for -A.
-e Print externals and statics only. This option applies to 32-bit
objects only and is ignored for 64-bit objects.
-f Produce full output. (This option is obsolete and does nothing
and will be removed in a future release).
-g Print only globally-visible names.
-h Do not print headers.
-l Adds to the type field displayed in -p format by printing a '*'
for weak names. Has no effect on other formats or on -B format.
Page 2
NM(1) NM(1)
-n When used alone or with -A, sort symbols by name. By name is the
default sort order for -B.
When used with -B, sort all symbols by value.
-o When used alone or with -A, print the value field in octal.
When used with -B, prepend the filename to output line. This is
useful for grepping through nm of libraries.
-p Produce easily parsable, terse output.
-r Prepend the name of the object file or archive to each output
line (Berkeley or XPG style) or name (ATT or default style).
-u Print only undefined symbols.
-v Sort symbols by value.
-x Print value field in hexadecimal. This is the default value
field radix for -B.
-T Only applies to the 32-bit output format. Truncate long names,
inserting a `*' as the last printed character. (Since symbol
names have been moved to the last column, the problem of overflow
is removed and this option is no longer necessary.)
-V Print version information on standard error.
-P In XPG4 mode, write information in a portable output format
according to the XPG standard.
-t format
In XPG4 mode, write each numeric value in the specified format.
The format should be one of the following:
d The offset will be written in decimal.
o The offset will be written in octal.
x The offset will be written in hexadecimal.
For 32-bit objects nm -B produces Berkeley output format with address or
value field followed by a letter showing what section the symbol is in
and the name of the symbol. Followed, if the symbol is a weak symbol, by
(weak).
These section letters describe the information that nm generates:
T External text.
t Local text.
Page 3
NM(1) NM(1)
D External initialized data.
d Local initialized data.
B External zeroed data.
b Local zeroed data.
A External absolute.
a Local absolute.
U External undefined.
G External small initialized data.
g Local small initialized data.
I Init section (IRIX4 static shared library initialization
code).
S External small zeroed data.
s Local small zeroed data.
R External read only.
r Local read only.
C Common.
E Small common.
The following section letters were frequently emitted by nm in earlier
releases but are now rarely emitted.
N Nil storage class, compiler internal usage.
V External small undefined.
b Fortran based variable
X Exception data
P Procedure section (not a normal variable).
F Fini section.
o Non GP data item (item not put in a small data area even
though it may be small enough to fit).
Page 4
NM(1) NM(1)
In XPG4 mode the format is specified by the XPG4 standard. The output is
sorted alphabetically by symbol name. The following information is
output:
Object or library name, if -A is specified
Name Symbol name
Type Symbol type, which will be one of the following single
characters (or one of the Berkeley format letters where
non-conflicting with the following table).
A Global absolute symbol
a Local absolute symbol.
B External zeroed data.
b Local zeroed data.
D Global data symbol.
d Local data symbol.
T Global text symbol.
t Local text symbol.
U Undefined symbol.
Value The value of the symbol.
Size The size of the symbol (0 if size not available).
In some previous releases the behavior of -rB was very different from -Br
(in this case the 'r' did nothing). This did not appear to be
intentional and was certainly undocumented. Now they both do the same
thing.
collide(1), elfdump(1), dwarfdump(1), stdump(1), odump(1), nlist(3e)
PPPPaaaaggggeeee 5555 [ Back ]
|