Displays information about symbols in object files, executable files, and object-file libraries.
nm [ -A ] [ -C ] [ -X {32|64|32_64|d64| any}] [ -f ] [ -h ] [ -l ] [ -p ] [ -r ] [ -T ] [ -v ] [ -B | -P ] [ -e | -g | -u ] [ -d | -o | -x | -t Format ] File ...
The nm command displays information about symbols in the specified File, which can be an object file, an executable file, or an object-file library. If the file contains no symbol information, the nm command reports the fact, but does not interpret it as an error condition. The nm command reports numerical values in decimal notation by default.
The nm command writes the following symbol information to standard output:
The nm command reports either the library or the object name associated with the file only if you specify the -A option.
The nm command represents the file's symbol type with one of the following characters (with weak symbols represented by the same characters as global symbols):
Item | Description |
---|---|
A | Global absolute symbol. |
a | Local absolute symbol. |
B | Global bss symbol. |
b | Local bss symbol. |
D | Global data symbol. |
d | Local data symbol. |
f | Source file name symbol. |
L | Global thread-local symbol (TLS). |
l | Static thread-local symbol (TLS). |
T | Global text symbol. |
t | Local text symbol. |
U | Undefined symbol. |
The nm command reports the size associated with the symbol, if applicable.
Item | Description |
---|---|
-A | Displays either the full path name or library name of an object on each line. |
-B | Displays output in the Berkeley Software Distribution (BSD)
format:
|
-C | Suppresses the demangling of C++ names. The default is to
demangle all C++ symbol names. Note: Symbols from C++ object files
have their names demangled before they are used.
|
-d | Displays a symbol's value and size as a decimal. This is the default. |
-e | Displays only static and external (global) symbols. |
-f | Displays full output, including redundant .text, .data, and .bss symbols, which are normally suppressed. |
-g | Displays only external (global) symbols. |
-h | Suppresses the display of output header data. |
-l | Distinguishes between WEAK and GLOBAL symbols by appending
a * to the key letter for WEAK symbols. If used with the -P option,
the symbol type for weak symbols is represented as follows:
|
-o | Displays a symbol's value and size as an octal rather than a decimal number. |
-P | Displays information in a standard portable output format:
This format displays numerical values in hexadecimal notation, unless you specify a different format with the -t, -d, or -o flags. The -P flag displays the library/object name field only if you specify the -A flag. Also, the -P flag displays the size field only for symbols for which size is applicable. |
-p | Does not sort. The ouput is printed in symbol-table order. |
-r | Sorts in reverse order. |
-t Format | Displays numerical values in the specified format, where
the Format parameter is one of the following notations:
|
-T | Truncates every name that would otherwise overflow its column, making the last character displayed in the name an asterisk. By default, nm displays the entire name of the symbols listed, and a name that is longer than the width of the column set aside for it causes every column after the name to be misaligned. |
-u | Displays only undefined symbols. |
-v | Sorts output by value instead of alphabetically. |
-x | Displays a symbol's value and size as a hexadecimal rather than a decimal number. |
-X mode | Specifies the type of object file nm should examine.
The mode must be one of the following:
The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes nm to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable. |
This command returns the following exit values:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
nm -e a.out
nm -xv a.out
nm -X64 /usr/lib/libc.a
Item | Description |
---|---|
/usr/ccs/bin/nm | Contains the nm command. |