nm — Display symbol table of object, library, or executable files

Format

nm [–AaefgMnoPprsuv] [–t format] file …

Description

nm displays the symbol table associated with an object, archive library of objects, or executable files.

By default, nm lists the symbols in file in alphabetical order by name and provides the following information about each:
  • File or object name (if you specified –A)
  • Symbol name
  • Symbol type. Not all of these symbol types are available on all systems. For instance, not all systems support the ability to determine different segment information.
    A
    Absolute symbol, global
    a
    Absolute symbol, local
    B
    Uninitialized data (bss), global
    b
    Uninitialized data (bss), local
    D
    Initialized data (bbs), global
    d
    Initialized data (bbs), local
    F
    File name
    l
    Line number entry (see the –a option)
    N
    No defined type, global. This is an unspecified type, compared to the undefined type U.
    n
    No defined type, local. This is an unspecified type, compared to the undefined type U.
    S
    Section symbol, global
    s
    Section symbol, local
    T
    Text symbol, global
    t
    Text symbol, local (static)
    U
    Undefined symbol
  • Symbol value
  • Symbol size, if applicable

Options

–A
Prefixes each line with the file name or archive member.
–a
Displays all symbols, including line number entries on systems that support them.
–e
Displays only global (external) and static symbols.
–f
Displays full output. This is the default because output is not suppressed.
–g
Displays only global symbols.
-M
Inserts three columns in the output before each symbol name. The format of these columns is as follows:
rmode amode compiler_options
The rmode and amode column will display one of the following:
     24		24 bit mode
     31		31 bit mode
     64		64 bit mode
     ANY		ANY mode
     MIN		MIN mode 
     ---		Undetermined or not/applicable
The compiler options field shows a character for each compiler option determined to be in effect or a dash if none are in effect:
I
Symbol is compiled with IPA. Note that IPA is not seen when running nm against an executable because that information is no longer available.
X
Symbol is compiled with XPLINK.
–n
Is equivalent to –v.
–o
Displays output in octal (same as –t o).
–P
Displays output in a portable POSIX-compliant format, with blanks separating the output fields.
  • If you specified –A and file is not a library, the format is:
    file: name type value size.
  • If you specified –A and file is a library, the format is:
    file [object_file] : name type value size
    where object_file is the object file in the library that contains the symbol that is being described.
  • If you did not specify –A, the format is:
    name type value size
  • If you did not specify the –t option, nm displays value and size in hexadecimal.
  • If you did not specify –A and the command line contains more than one file, or file is a library, nm displays a line preceding the list of symbols for each specified file or each object file in a specified library. If file is a library, this line has the following format:
    file[object_file]:
    If file is not a library, the format is:
    file:
–p
Does not sort output.
–r
Reverses sort order.
–s
Includes symbol size for each symbol.
–t format
Defines the numeric value formatting base. The format is one of d, o, or x, for decimal, octal, or hexadecimal, respectively. If this option is not used, numbers are displayed in decimal.
–u
Displays only undefined symbols.
–v
Sorts output by value.
–x
Displays information in hexadecimal (same as –t x).

Localization

nm uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_COLLECT
  • LC_CTYPE
  • LC_MESSAGES
  • LC_TIME

See Localization for more information.

Exit values

0
Successful completion
1
Failure due to any of the following:
  • Invalid command-line option
  • Missing file name
  • Unknown symbol table type
  • Invalid library file
  • End-of-file found in library
  • Bad record in the library
  • Out of memory
If a file does not contain a symbol table, nm displays a warning and goes to the next file, but this is not considered an error.

Portability

POSIX.2, X/Open Portability Guide, UNIX systems.

The –a, –e, –f, –n, –o, –p, –r, –s, and –x options are not part of the POSIX standard.

The –a, –n, –p, –r, –s, and –t d, options are not part of the X/OpenX/Open standard.

Related information

ar, size, strip