NM(1) — USER COMMANDS
NAME
nm − print name list
SYNOPSIS
nm [ −gnoprsuaC ] [ [ filename ] ...
DESCRIPTION
nm prints the name list (symbol table) of each object filename in the argument list. If an argument is an archive, a listing for each object file in the archive will be produced. If no filename is given, the symbols in a.out are listed.
Output Format
Each symbol name is preceded by its value (blanks if undefined) and one of the letters:
A absolute
B bss segment symbol
C common symbol
D data segment symbol
f filename
t a static function symbol
T text segment symbol
U undefined
− debug, giving symbol table entries (see −a below)
The type letter is upper case if the symbol is external, and lower case if it is local. The output is sorted alphabetically.
If the symbol is a C++ mangled symbol, nm will print out its demangled format when −C is used. All mangled C++ symbols are bracketed by [ ] following the demangled symbol. For regular mangled C++ function names (including member and non-member functions), 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 nm 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 nm 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
−a Print all symbols.
−C Demangle symbols as if they are C++ names.
−g Print only global (external) symbols.
−n Sort numerically rather than alphabetically.
−o Prepend file or archive element name to each output line rather than only once.
−p Do not sort; print in symbol-table order.
−r Sort in reverse order.
−s Sort according to the size of the external symbol (computed from the difference between the value of the symbol and the value of the symbol with the next higher value). This difference is the value printed.
−u Print only undefined symbols.
Options may be used in any order, either singly or in combination, and may appear anywhere in the command line. Therefore, both nm name −e −v and nm −ve name print the static and external symbols in name, with external symbols sorted by value.
EXAMPLE
example% nm
prints the symbol list of the file named a.out, the default output file for the C/C++ compiler(s).
NOTE
Some C++ symbols contain file name information. A SunOS file name path can contain characters (such as ‘.’ and ‘/’) that cannot be used to encode assembler symbols. Those characters are transformed into ‘_’. For example, ../stream_io.c is represented as ___stream_io_c in C++ mangled symbol. nm does not second-guess or demangle ‘_’ in the file name path string.
LIMITATIONS
The demangling scheme will not handle the functions that take more than 35 arguments.
SEE ALSO
ar(1V), as(1), nm(1), cc(1V), ld(1), tmpnam(3S), a.out(5), ar(5), coff(5)
Sun Release 4.1 — Last change: 29 May 1992