nm(1) — Commands
NAME
nm − name list dump of object files
SYNOPSIS
nm [−B|-P|-S] [-abdfhnoprvwxATV] [−e|-g|-u] [−t format] [ file... ]
DESCRIPTION
The nm command prints formatted listings of the symbol and external sections of an object file symbol table. A file can be an object or an archive. If you do not specify a file, this command assumes a.out.
These section letters describe the information that nm generates in the default, portable (−P), and Berkeley (−B) formats:
N nil storage class, compiler internal usage
T external text
t local text
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
S external small zeroed data
s local small zeroed data
R external read only
r local read only
C common
E small common
V external small undefined
The System V format (−S) and the −a specified debug format provide an expanded listing with these columns:
Name the symbol or external name
Value value field for the symbol or external, usually an address or interesting debugging information
Class the symbol type
Type the symbol’s language declaration
Size the symbol’s size (accurate only for objects compiled with debugging information preserved as in cc −g)
Index the symbol’s index field
Section
the symbol’s storage class
NOTE: In the System V (−S) format, every effort was made to map the field’s functionality into System V nomenclature.
FLAGS
The nm command accepts these options:
−aPrints debugging information using System V format
−bFor Berkely (−B) format only, prints the value field in octal. Equivalent to −t o.
−dPrints the value field in decimal (default for System V and default output formats). Equivalent to −t d.
−ePrints external and statics only
−fProduces full output. (The nm command still accepts this old option, but ignores it.)
−gPrints only global symbols
−hDoes not print headers
−nFor Berkeley (−B) format, sorts all symbols by value. For all other formats, sorts external symbols by name (default for Berkeley).
−oPrints the value field in octal for all formats except Berkeley (−B). (Equivalent to −t o.) For Berkeley format, prepends the filename to each symbol. (Equivalent to −A)
−pPrints symbols as they are found in the file (the System V default)
−rReverses the sense of a value or name sort
−t format
Write each numeric value in the specified format as follows:
dThe offset is written in decimal (default for System V and default output formats). Equivalent to −d.
oThe offset is written in octal. Equivalent to −o.
xThe offset is written in hexadecimal (default for Berkeley and portable formats). Equivalent to −x.
−uPrints only undefined symbols
−vSorts external symbols by value
−wIdentifies weak symbols using an asterisk (∗). For the default, portable (−P), and Berkeley (−B) formats, the asterisk follows the symbol type letter. For System V (−S), an additional column is added to the end of each line containing an asterisk for weak symbols.
−xPrints value field in hexadecimal (default for Berkeley and portable formats). Equivalent to −t x.
−APrepends the filename to each symbol. This is useful for using the grep command to check through nm listings of libraries.
−BPrints Berkeley (4.3 BSD)-style output. This format produces an address or value field followed by a letter showing what section the symbol or external is located in. The third and final field is the name of the symbol or external.
−PPrints output in a portable format. This format prints lines containing each symbol’s name, type (single letter), value, and size.
−SPrints AT&T System V-style output.
−TTruncates long names, inserting a ‘∗’ as the last printed character
−VPrints version information on stderr
RELATED INFORMATION
Programmer’s Guide
Assembly Language Programmer’s Guide