nm Command


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:

  • Library or Object Name

    The nm command reports either the library or the object name associated with the file only if you specify the -A option.

  • Symbol Name
  • Symbol Type

    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.
  • Value
  • Size

    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:
value   type   name
-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:
Weak Data Symbol
Weak Text Symbol
Weak Undefined Symbol
Weak bss Symbol
-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:
library/object name   name   type   value   size

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:
Decimal notation. This is the default format for the nm command.
Octal notation.
Hexadecimal notation.
-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:
Processes only 32-bit object files
Processes only 64-bit object files
Processes both 32-bit and 64-bit object files
Examines discontinued 64-bit XCOFF files (magic number == U803XTOCMAGIC).
Processes all of the supported object files.

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.

Note: The nm command supports the (double hyphen) flag. This flag distinguishes a File operand if the file name can be misinterpreted as an option. For example, to specify a file name that begins with a hyphen, use the flag.

Exit Status

This command returns the following exit values:

Item Description
0 Successful completion.
>0 An error occurred.


  1. To list the static and external symbols of the object file a.out, enter:
    nm -e a.out
  2. To display symbol sizes and values as hexadecimal and sort the symbols by value, enter:
    nm -xv a.out
  3. To display symbol of all 64-bit objects in libc.a, ignoring all 32-bit objects:
    nm -X64 /usr/lib/libc.a


Item Description
/usr/ccs/bin/nm Contains the nm command.