nm(1)
NAME
nm − print name list of an object file
SYNOPSIS
nm [ −CefhlnoprRTuvVx ] filename...
DESCRIPTION
The nm command displays the symbol table of each ELF or COFF object file, specified by filename(s). The file may be a relocatable or absolute ELF or COFF object file; or it may be an archive of relocatable or absolute ELF or COFF object files. For each symbol, the following information will be printed:
Index The index of the symbol. (The index appears in brackets.)
Value 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.
Size The size in bytes of the associated object.
Type 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).
Bind 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.
Other A field reserved for future use, currently containing 0.
Shndx 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.
Name The name of the symbol.
If the function name is a C++ mangled symbol, nm will print out its demangled format. All mangled C++ symbols are bracketed by [ ] following the demangled symbol. For regular mangled C++ function names (including member and non-member functions), the function prototype is used as its demangled format. For example, ___ct__13Iostream_initFv is printed as:
Iostream_init::Iostream_init().
C++ static constructors and destructors are demangled and printed in the following format:
static constructor function for <file_name>
or
static destructor function for <file_name>.
For example, ___std_____stream_in_c___Fv is demangled as static destructor function for ___stream_in_c.
For C++ virtual table symbols, its mangled name takes the following format:
___vtbl__<class>
___vtbl__<root_class>__<derived_class>
In the gprof++ output, the demangled names for the virtual table symbols are printed as
virtual table for <class>
virtual table for class <derived_class> derived from <root_class>
For example, the demangled format of
___vtbl__7fstream
is
virtual table for fstream
and the demangled format of
___vtbl__3ios__18ostream_withassign
is
virtual table for class ostream_withassign derived from ios.
Some C++ symbols are pointers to the virtual tables, their mangled names take the following format:
___ptbl__<class>___<Filename>
___ptbl__<root_class>__<derived_class>___<Filename>
In the gprof++ output, the demangled names for these symbols are printed as:
pointer to virtual table for <class> in <Filename>
pointer to virtual table for class <derived class> derived from <root_class> in <Filename>
For example, the demangled format of
___ptbl__3ios_____stream_fstream_c
is
pointer to the virtual table for ios in __stream_fstream_c
and the demangled format of
___ptbl__3ios__11fstreambase_____stream_fstream_c
is
pointer to the virtual table for class fstreambase derived from ios in ___stream_fstream_c
OPTIONS
The output of nm may be controlled using the following options:
−C Demangle C++ function and variable names before printing them out.
−e See NOTES below.
−f See NOTES below.
−h Do not display the output heading data.
−l Distinguish between WEAK and GLOBAL symbols by appending a ∗ to the key letter for WEAK symbols.
−n Sort external symbols by name before they are printed.
−o Print the value and size of a symbol in octal instead of decimal.
−p Produce easily parsable, terse output. Each symbol name is preceded by its value (blanks if undefined) and one of the letters U (undefined), 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 a ∗; if the symbol’s binding attribute is GLOBAL, the key letter is upper case.
−r Prepend the name of the object file or archive to each output line.
−R Print the archive name (if present), followed by the object file and symbol name. If the −r option is also specified, this option is ignored.
−T See NOTES below.
−u Print undefined symbols only.
−v Sort external symbols by value before they are printed.
−V Print the version of the nm command executing on the standard error output.
−x Print the value and size of a symbol in hexadecimal instead of decimal.
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.
SEE ALSO
as(1), dump(1), ld(1), a.out(4), ar(4)
NOTES
The following options are obsolete because of changes to the object file format and will be deleted in a future release.
−e Print only external and static symbols. The symbol table now contains only static and external symbols. Automatic symbols no longer appear in the symbol table. They do appear in the debugging information produced by cc −g, which may be examined using dump(1).
−f Produce full output. Redundant symbols (such as .text, .data, and so forth). which existed previously do not exist and producing full output will be identical to the default output.
−T By default, nm prints the entire name of the symbols listed. Since symbol names have been moved to the last column, the problem of overflow is removed and it is no longer necessary to truncate the symbol name.
SunOS 5.1/SPARC — Last change: 14 Jun 1991