nm(1)
NAME
nm − print name list of common object file
SYNOPSIS
/usr/ccs/bin/nm [−AefghnNqrTuvV] [−d|−o |−x] [−p|−P] [−t format] file ...
DESCRIPTION
The nm command displays the symbol table of each object file, file.
file can be a relocatable object file or an executable object file, or it can be an archive of relocatable or executable object files.
There are three general output formats: the default (neither −p nor −P specified), −p specified, and −P specified. The output formats are described after the "Options" subsection.
Options
nm recognizes the following options:
−A Prefix each output line with the name of the object file or archive, file. Equivalent to −r.
−d 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.
−e Display only external and static symbols. This option is ignored (see −f).
−f Display full output. This option is in force by default.
−g Display only external (global) symbol information.
−h Do not display the output header data.
−n Sort symbols by name, in ascending collation order, before they are printed. This is the default. See "Environment Variables" in EXTERNAL INFLUENCES below.
−N Display symbols in the order in which they appear in the symbol table.
−o Display the value and size of a symbol in octal. Equivalent to -t o.
−p Display information in a blank-separated output format. Each symbol name is preceded by its value (blanks if undefined) and one of the letters U (undefined), A (absolute), T (text symbol), D (data symbol), B (bss symbol), or C (common symbol). If the symbol is local (nonexternal), the type letter is in lowercase. If the symbol is a secondary definition, the type letter is followed by the letter S. Note that −p is not compatible with −P.
−P Display information in a portable output format, as specified below, to standard output. Note that −P is not compatible with −p.
−q Silence some warning messages.
−r Prefix each output line with the name of the object file or archive, file. Equivalent to −A.
−t format Display each numeric value in the specified format. format can be one of:
d Display the value and size of a symbol in decimal. This is the default for the default format or the −p format. Equivalent to -d.
o Display the value and size of a symbol in octal. Equivalent to -o.
x Display the value and size of a symbol in hexadecimal. This is the default for the −P format. Equivalent to -x.
−T Truncate every name that would otherwise overflow its column and place an asterisk as the last character in the displayed name to mark it as truncated. If −A or −r is also specified, the file prefix is truncated first.
By default, nm prints the entire name of the symbols listed. Since object files can have symbol names with an arbitrary number of characters, a name that is longer than the width of the column set aside for names will overflow its column, forcing every column after the name to be misaligned.
−u Display undefined symbols only.
−v Sort symbols by value before they are printed.
−V Display the executing version of the nm command on standard error.
−x Display the value and size of a symbol in hexadecimal. This is the default for the −P format. Equivalent to -t x.
Default Output Format
If the default (neither the −p nor the −P option) output format is specified, each symbol has the following columns, separated by vertical bars (|). The default for numbers is decimal (−d or −t d).
If decimal:
"%20s|%10d|%6s|%7s|%s", name, value, scope, type, subspace
If octal:
"%20s|%012o|%6s|%7s|%s", name, value, scope, type, subspace
If hexadecimal:
"%20s|0x%08x|%6s|%7s|%s", name, value, scope, type, subspace
The descriptions are explained below:
name The name of the symbol.
value Its value expressed as an offset or an address depending on its storage class.
scope The scope of the symbol (external, sdef, static, or undefined). The sdef scope indicates an external symbol that is flagged as a secondary definition.
type The type of the symbol (absolute, arg_ext, code, data, entry, milli_ext, millicode, module, null, oct_dis, plabel, pri_prog, sec_prog, storage, stub, sym_ext).
subspace The subspace to which the symbol belongs.
Output Format for −p
If the −p option is specified, information is displayed using the following portable C-language formats. The default for numbers is decimal (−d or −t d).
If decimal: "%010d %s %s", value, type, name
If octal: "%012o %s %s", value, type, name
If hexadecimal: "0x%08x %s %s", value, type, name
If −A or −r, the line is preceded by: "%20s:", file
Output Format for −P
If the −P option is specified, information is displayed using the following portable C-language formats. The default for numbers is hexadecimal (−x or −t x). In the format string, %s represents string output; %d represents decimal output; %o represents octal output; %x represents hexadecimal output; \n represents newline; all other characters represent themselves.
• If decimal is specified:
"%s%s %s %d %d\n", library-object, name, type, value, size
• If octal is specified:
"%s%s %s %o %o\n", library-object, name, type, value, size
• If hexadecimal is specified, or by default:
"%s%s %s %x %x\n", library-object, name, type, value, size
where library-object is a string preformatted as follows:
• If −A and −r are not specified, library-object is an empty string.
• If −A or −r is specified, and the corresponding file operand does not name a library:
"%s: ", file
• If −A or −r is specified and the corresponding file operand names a library, object-file names the object file in the library containing the symbol being described:
"%s[%s]: ", file, object-file
If −A and −r are not specified, and if more than one file operand is specified, or if a single file operand that names a library is specified, then nm prints a line identifying the object containing the symbols before the lines containing those symbols, in one of the following forms:
• If the corresponding file operand does not name a library:
"%s:\n", file
• If the corresponding file operand names a library, object-file names the object file in the library containing the symbol being described:
"%s[%s]:\n", file, object-file
EXTERNAL INFLUENCES
Environment Variables
The following internationalization variables affect the execution of nm:
LANG determines the locale category for native language, local customs and coded character set in the absence of LC_ALL or other LC_* environment variables. If LANG is not specified or is null, it defaults to C (see lang(5)).
LC_ALL, if set to a nonempty string value, determines the values for all locale categories and has precedence over LANG and other LC_* environment variables.
LC_COLLATE determines the locale category for character collation.
LC_CTYPE determines the locale category for character handling functions.
LC_MESSAGES determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
LC_NUMERIC determines the locale category for numeric formatting.
NLSPATH determines the location of message catalogues for processing LC_MESSAGES.
If an internationalization variable is not specified or is null, it defaults to the value of LANG.
If LANG is not specified or is null, it defaults to C (see lang(5)).
If any internationalization variable contains an invalid setting, then all internationalization variables default to C (see environ(5)).
International Code Set Support
Single-byte character code sets are supported.
EXAMPLES
Display which object files have undefined references for the symbol leap:
nm −rup *.o | grep leap
Display which object files have a definition for the text symbol leap:
nm −rp *.o | awk ’{ if ($3 == "T" && $4 == "leap") { print $0 } }’
WARNINGS
By default, nm now sorts symbols by name (the −n option). To turn off sorting, use the −N option.
Some options added for standards conformance duplicate the functionality of options that previously existed. This duplication has been retained for backward compatibility.
SEE ALSO
System Tools
cc(1) HP-UX ANSI C compiler
ld(1) Link editor
Miscellaneous
crt0(3) Execution startup routine
end(3C) Symbol of the last locations in program
STANDARDS CONFORMANCE
nm: SVID2, SVID3, XPG2, XPG3, XPG4
Hewlett-Packard Company — HP-UX Release 10.20: July 1996