[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 4

nm Command

The nm command includes information for nm on a POWER-based platform and an nm on an Itanium-based platform.

nm Command on POWER-based Platform


Displays information about symbols in object files, executable files, and object-file libraries.


nm [ -A ] [ -C ] [ -X {32|64|32_64}] [ -f ] [ -h ] [ -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:


-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.
-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 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.
-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.
-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

The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set withe 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:

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


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

Related Information

The ar command, as command, ld command, size command, strip command.

The a.out file, ar file.

Commands Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.

nm Command on Itanium-based Platform


Print name list of an object file.


nm [ -goxhtnvsnurplCVAPR ] files


The nm command displays the symbol table of each ELF object file, specified by file(s). The file may be a relocatable or absolute ELF object file; or it may be an archive of relocatable or absolute ELF object files. For each symbol, the following information will be printed:

The index of the symbol. (The index appears in brackets.)

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.

The size in bytes of the associated object.

A symbol is of 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).

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 than "GLOBAL".

This field currently indicates the visibility of the symbol. 0 indicates default visibility. "HIDDEN" means the symbol is visible solely within the object but not exported to other objects. "PROT" means the symbol is "protected". Any reference to the symbol from within the object will go to this definition, even if other definitions are present and would normally take precedence.

Except for three 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.

The name of the symbol.

The output of nm may be controlled using the following options:

Only print symbols with binding types GLOBAL and WEAK.

Print the value and size of a symbol in octal instead of decimal.

Print the value and size of a symbol in hexadecimal instead of decimal.

-t d | o | x
Set output format to decimal, octal or hexadecimal. (Decimal is the default; -t o is equivalent to -o; -t x is equivalent to -x)

Do not display the output heading data.

Sort external symbols by value before they are printed.

Print section names instead of section indices.

Sort external symbols by name before they are printed.

Print undefined symbols only.

Prepend the name of the object file or archive to each symbol name. This option is ignored if -P is specified.

-p [-l]
Produce terse output that can be parsed easily. Each symbol name is preceded by its value (blanks if undefined) and one of the letters "U" (undefined symbol reference), "A" (absolute symbol) "B" (symbol defined in .bss or a common symbol) "N" (symbol has no type), "D" (data object symbol), "T" (text symbol), "S" (section symbol), or "F" (file symbol). If the symbol's binding attribute is "LOCAL", the key letter is lower case; if the symbol's binding attribute is "WEAK", the key letter is upper case (if the -l modifier is specified, the upper case key letter is followed by an "*"); if the symbol's binding attribute is "GLOBAL", the key letter is upper case.

Print C++ names decoded.

Print on the standard error output the version number of the nm command being executed.

Prepend the name of the object file and archive to each output line.

-P [-l]
Alternate form of terse, easily parseable output (see -p). The symbol name appears first, followed by a keyletter (as described under -p), the symbol's value and its size. The value and size fields are printed in hexadecimal, by default.

Prepend the name of the object file and archive to each symbol name. This option is ignored if -P is specified.

Options may be used in any order, either singly or in combination, and may appear anywhere in the command line. When conflicting options are specified (such as nm -v -n) the first is taken and the second ignored with a warning message to the user.


The a.out file format, ar file format.

The ar command, as command, cc command, dump command, and ld command.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]