nm(CP)
nm --
print name list of an object file
Syntax
nm [-b coff] [-oxhvnefurplCVT] filename...
nm++ [-b coff] [-oxhvnefurplCVT] filename...
Description
The
nm(CP)
command displays the symbol table of each
ELF or COFF
object file,
filename.
filename can be a relocatable or absolute
ELF or COFF object file
or an archive of relocatable or absolute ELF or COFF
object files.
The nm++ command pipes the output of
nm through a filter
that translates names mangled by C++ to human-readable forms.
This makes the output of nm more readable.
C names are passed unchanged.
Unless the option -b coff is specified (see
``Notes''),
the following information is printed
for each symbol in an object file:
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
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.
The output of nm can be controlled using the following options:
-o-
Print the value and size of a symbol in octal instead of decimal.
-x-
Print the value and size of a symbol in hexadecimal instead
of decimal.
-h-
Do not display the output header data.
-v-
Sort external symbols by value before they are printed.
-n-
Sort external symbols by name before they are printed.
-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.
To examine automatic symbols, use the
dump(CP)
command.
-f-
Produce full output.
Redundant symbols (such as .text, .data, and so on) which
existed previously do not exist and producing full
output will be identical to the default output.
This option is obsolete.
-u-
Print undefined symbols only.
-r-
Prepend the name of the object file or archive to each output line.
-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 key letters.
The case of the key letter is affected by the symbol's binding attribute:
LOCAL-
The key letter is lower case.
WEAK-
The key letter is upper case
(if the -l modifier is specified, the upper case
key letter is followed by an *).
GLOBAL-
The key letter is upper case.
The key letter is from the set [UNDTSF]:
U-
undefined
N-
symbol has no type
D-
data object symbol
T-
text symbol
S-
section symbol
F-
file symbol
-C-
Print C++ names decoded.
-V-
Print the version of the nm command executing on the
standard error output.
-T-
Truncate every name which would otherwise overflow its column and place an
asterisk as the last character in the displayed name.
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.
This option is obsolete.
When conflicting options are specified (such as
nm -v -n)
the first is used and the second ignored with a
warning message to the user.
Notes
The output format is different from that in previous releases.
If all input files are in COFF format,
the option -b coff allows you to display the symbol table
in the old format. With the option -b coff,
the following information is printed
for each symbol in a COFF file:
Name-
The name of the symbol.
Value-
Its value expressed as an offset or an address depending on its storage class.
Class-
Its storage class.
Type-
Its type and derived type.
If the symbol is an instance of a structure or of a union, then
the structure or union tag is given following the type (for
example, struct-tag).
If the symbol is an array, then the array dimensions are given
following the type (for example, char[ n ][ m ]).
The object file must have been compiled with the
-g option of the
cc(CP)
command for this information to appear.
Size-
Its size in bytes, if available.
The object file must have been compiled with the
-g option of the
cc(CP)
command for this information to appear.
Line-
The source line number at which it is defined, if available.
The object file must have been compiled with the
-g option of the
cc(CP)
command for this information to appear.
Section-
For storage classes static and external, the object file section
containing the symbol (for example, text, data, or bss).
In addition, the options -e, -f, -p and
-T are affected when the option -b coff is used:
-e-
Print only external and static symbols.
-f-
Produce full output.
Redundant symbols (.text, .data,
.lib, and .bss) are not suppressed.
-p-
Produce terse output that can be parsed easily.
Each symbol name is preceded by
its value (blanks if undefined) and one of
the key letters.
If the symbol is local (non-external), the key letter is in lowercase.
The key letter is from the set [UABTDSRFC]:
U-
undefined
A-
absolute
B-
.bss symbol
T-
text segment symbol
D-
data segment symbol
S-
user-defined segment symbol
R-
register symbol
F-
file symbol
C-
common symbol
-T-
With the option -b coff,
nm prints the entire name of the symbols listed.
Since object files can have symbol names with an arbitrary
number of characters, a name that is longer than the width of
the column set aside for names overflows its column, making
every column after the name misaligned.
The -T option makes nm truncate every
name which would otherwise overflow its column and place an
asterisk as the last character in the displayed name to mark it as truncated.
Warning
This utility determines whether an object file is in
ELF or COFF format
and executes the appropriate binaries in each case.
Since this utility relies on the files in /usr/ccs/bin/elf
and /usr/ccs/bin/coff,
changing or moving any of those files results in an error.
Files
TMPDIR/-
Temporary files.
TMPDIR is usually /usr/tmp but can be
re-defined by setting the environment variable TMPDIR
(see
tempnam(S)
in
tmpnam(S)).
See also
a.out(FP),
ar(FP),
as(CP),
c++filt(CP),
cc(CP),
dump(CP),
ld(CP),
tmpnam(S)
Standards conformance
nm is conformant with:
X/Open Portability Guide, Issue 3, 1989
.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003