.TH nm "" "" Command
.PC "Print a program's symbol table"
\fBnm\fR [ \-\fBadgnopru\fR ] \fIfile\fR ...
.PP
.HS
.SH Options:
.IC \fB\-a\fR
Print all symbols
.IC \fB\-d\fR
Print only definitions
.IC \fB\-g\fR
Print only global symbols
.IC \fB\-n\fR
Sort numerically (default, sort by name)
.IC \fB\-o\fR
Prepend file or member name to each line
.IC \fB\-p\fR
Print in symbol table order (no sort)
.IC \fB\-r\fR
Reverse order of sort
.IC \fB\-u\fR
Print undefined symbols
.Pp
\fIfile\fR may be an object file or an archive.
.HE
The command
.B nm
prints the symbol table of each
.IR file .
It can read binary files produced by the compiler, assembler, or linker.
.PP
When a C source file is compiled with the
\fB\-c\fR switch to the \fBcc\fR command, or when
a file of assembly language is assembled,
the result is an object module, which is signified by the suffix \fB.o\fR.
.PP
The linker \fBld\fR links multiple object modules to form an executable program.
Frequently used object modules often are grouped by the archiver \fBar\fR
into a \fIlibrary\fR, which is signified by the suffix \fB.a\fR.
.B nm
can read all three kinds of files: .o, .a, and fully linked executables.
.SH Options
.B nm
recognizes the following options:
.IP "\fB\-a\fR (\*(CO 286 only)" 0.3i
Print all symbols.
Normally,
.B nm
prints names that are in C-style format and ignores symbols with names
inaccessible from C programs.
.IP \fB\-d\fR
Print only defined symbol.
.IP \fB\-g\fR
Print only global symbols.
.IP \fB\-n\fR
Sort numerically rather than alphabetically.
.B nm
uses unsigned compares when sorting symbols with this option.
.IP \fB\-o\fR
Append the file name to the beginning of each output line.
.IP \fB\-p\fR
Print symbols in the order in which they appear within the symbol table.
.IP \fB\-r\fR
Sort in reverse-alphabetical order.
.IP \fB\-u\fR
Print only undefined symbols.
.SH "Output Format"
The output of
.B nm
is a series of lines of the form:
.DS
	\fIsegment address symbol\fR
.DE
.PP
.I segment
gives the segment in which the symbol appears,
or \fBUNDEF\fR for undefined symbols.
.I address
is either the address in hexadecimal, or the length of a common variable.
.I symbol
names the symbol.
.PP
For example, if
.B foo.o
is a relocatable object module,
the output of the command
.B "nm -o foo.o"
would appears as follows:
.DM
	#nm foo.o
	UNDEF    00000000 _canl
	UNDEF    00000000 _stderr
	.text    0000077C acomp
	.text    00000034 acomp_old
	UNDEF    00000000 alloc
	.text    00000F28 archive
	.comm    00000004 asw
	.text    000003CC csymbol
	.comm    00000004 dsw
.DE
.SH "See Also"
.Xr "cc," cc
.Xr "commands," commands
.Xr "ld," ld
.Xr "size," size
.Xr "strip" strip
