nm(CP) 6 January 1993 nm(CP) Name nm - print name list of common object file Syntax nm [-oxhvnefurpVT] filename... Description The nm command displays the symbol table of each common object file, filename. filename may be a relocatable or absolute common object file, or it may be an archive of relocatable or absolute common object files. For each symbol, the following information will be printed: 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 will be given following the type (for example, struct-tag). If the sym- bol is an array, then the array dimensions will be given follow- ing the type (for example, char[ n ][ m ] ). Note that 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. Note that 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. Note that 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). The output of nm may 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. -f Produce full output. Print redundant symbols (.text, .data, .lib, and .bss), normally suppressed. -u Print undefined symbols only. -r Prepend the name of the object file or archive to each output line. -p Produce easily parsable, terse output. Each symbol name is preceded by its value (blanks if undefined) and one of the letters U (unde- fined), A (absolute), B (.bss symbol), T (text segment symbol), D (data segment symbol), S (user-defined segment symbol), R (register symbol), F (file symbol), or C (common symbol). If the symbol is local (non-external), the type letter is in lowercase. -V Print the version of the nm command executing on the standard error output. -T By default, nm prints the entire name of the symbols listed. Since object files can have symbols names with an arbitrary number of char- acters, a name that is longer than the width of the column set aside for names will overflow its column, forcing every column after the name to be misaligned. The -T option causes nm to 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. 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. Files TMPDIR/* Temporary files. TMPDIR is usually /usr/tmp but can be re-defined by setting the environment variable TMPDIR (see tempnam() in tmpnam(S)). Diagnostics ``nm: name: cannot open'' name cannot be read. ``nm: name: bad magic'' name is not a common object file. ``nm: name: no symbols'' The symbols have been stripped from name. Notes If you are using XENIX binaries, refer to the XENIX manual page for this utility for information on the appropriate usage with XENIX binaries. When all the symbols are printed, they must be printed in the order they appear in the symbol table in order to preserve scoping information. Therefore, the -v and -n options should be used only in conjunction with the -e option. The -n option generates an error with long name lists. To sort a long name list, instead of using the -n option, use the command line: nm executable | sort This utility determines whether an object file is in OMF or COFF format and executes the appropriate binaries in each case. Since this utility relies on the files in /lib/coff and /lib/xout, changing or moving any of those files results in an error. See also a.out(FP), ar(FP), as(CP), cc(CP), ld(CP), tmpnam(S) Standards conformance nm is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.