Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > N

nm(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

nm — print name list of common object file

SYNOPSIS

/usr/ccs/bin/nm [-ACefghlnNqrsTuUvV] [-d|-o |-x] [-p|-P] [-t format] file ...

DESCRIPTION

The nm command displays the symbol table of each object file, file.

There are three general output formats: the default (neither -p nor -P specified), -p specified, and -P specified. The output formats are described after the "Options" subsection.

By default, 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 will overflow its column, forcing every column after the name to be misaligned.

Options

nm recognizes the following options:

-A

Prefix each output line with the name of the object file or archive, file. Equivalent to -r.

-C

Demangle C++ names before printing them (ELF only).

-d

Display the value and size of a symbol in decimal. This is the default for the default format or the -p format. Equivalent to -t d.

-e

Display only external and static symbols. This option is ignored (see -f).

-f

Display full output. This option is in force by default.

-g

Display only external (global) symbol information.

-h

Do not display the output header data.

-l

Distinguish between weak and global symbols by appending * to the key letter of weak symbols. Only takes effect with -p and/or -P.

-n

Sort symbols by name, in ascending collation order, before they are printed. This is the default. See Environment Variables in EXTERNAL INFLUENCES below.

-N

Display symbols in the order in which they appear in the symbol table.

-o

Display the value and size of a symbol in octal. Equivalent to -t o.

-p

Display information in a blank-separated output format. Each symbol name is preceded by its value (blanks if undefined) and a letter to indicate type. A lowercase letter indicates a local (nonexternal) symbol.

A

(absolute)

B

(bss symbol)

C

(common symbol)

D

(data symbol)

M

(milli symbol) ELF only

N

(notype) ELF only

R

(section region)

S

(tstorage symbol) SOM only

T

(text symbol)

U

(undefined)

If the symbol is a secondary definition, the type letter is followed by the letter S.

Note that -p is not compatible with -P.

-P

Display information in a portable output format, as specified below, to standard output. Note that -P is not compatible with -p.

-r

Prefix each output line with the name of the object file or archive, file. Equivalent to -A.

-q

(SOM only) Silence some warning messages.

-s

Print the section index instead of the section name (ELF only).

-t format

Display each numeric value in the specified format. format can be one of:

d

Display the value and size of a symbol in decimal. This is the default for the default format or the -p format. Equivalent to -d.

o

Display the value and size of a symbol in octal. Equivalent to -o.

x

Display the value and size of a symbol in hexadecimal. This is the default for the -P format. Equivalent to -x.

-T

(SOM only) Truncate every name that would otherwise overflow its column and place an asterisk as the last character in the displayed name to mark it as truncated. If -A or -r is also specified, the file prefix is truncated first.

-u

Display undefined symbols only.

-U

Print the usage menu.

-v

Sort symbols by value before they are printed.

-V

Display the executing version of the nm command on standard error.

-x

Display the value and size of a symbol in hexadecimal. This is the default for the -P format. Equivalent to -t x.

Operands

nm recognizes the following operand:

file

A relocatable object file or an executable object file, or an archive of relocatable or executable object files.

Default Output Format - 32 bit

If the default (neither the -p nor the -P option) output format is specified, each symbol has the following columns, separated by vertical bars (|). The default for numbers is decimal (-d or -t d).

If decimal:

"%20s|%10d|%6s|%7s|%s", name, value, scope, type, subspace

If octal:

"%20s|%012o|%6s|%7s|%s", name, value, scope, type, subspace

If hexadecimal:

"%20s|0x%08x|%6s|%7s|%s", name, value, scope, type, subspace

Default Output Format - 64 bit

If the default (neither the -p nor the -P option) output format is specified, each symbol has the following columns, separated by vertical bars (|). The default for numbers is decimal (-d or -t d).

If decimal:

"[%u]%s|%22llu|%8u|%s|%s|%1d|%s|%s", index, value, size, type, bind, O, shndx, name

If octal:

"[%u]%s|%022llo|%010o|%s|%s|%1o|%s|%s", index, value, size, type, bind, O, shndx, name

If hexadecimal:

"[%u]%s|0x%016llx|0x%08x|%s|%s|%1x|%s|%s", index, value, size, type, bind, O, shndx, name

The descriptions are explained below:

name

The name of the symbol.

value

Its value expressed as an offset or an address depending on its storage class.

scope

The scope of the symbol (external, sdef, static, or undefined). The sdef scope indicates an external symbol that is flagged as a secondary definition.

type

The type of the symbol (absolute, arg_ext, code, data, entry, milli_ext, millicode, module, null, oct_dis, plabel, pri_prog, sec_prog, storage, stub, sym_ext, tstor).

subspace

The subspace to which the symbol belongs.

bind

Specifies the symbol binding type (local, weak, global).

O

This field is used for files that have large section tables (>65K sections). For smaller files, the value of this field is 0.

Shndx

Identifies the index of the section that the symbol belongs to.

Identifies the index of the symbol in the symbol table.

Output Format for -p

If the -p option is specified, information is displayed using the following portable C-language formats. The default for numbers is decimal (-d or -t d).

If decimal: "%010d %s %s", value, type, name

If octal: "%012o %s %s", value, type, name

If hexadecimal: "0x%08x %s %s", value, type, name

If -A or -r, the line is preceded by: "%20s:", file

Output Format for -P

If the -P option is specified, information is displayed using the following portable C-language formats. The default for numbers is hexadecimal (-x or -t x). In the format string, %s represents string output; %d represents decimal output; %o represents octal output; %x represents hexadecimal output; \n represents newline; all other characters represent themselves.

  • If decimal is specified:

    "%s %s %d %d\n", library-object, name, type, value, size

  • If octal is specified:

    "%s%s %s %o %o\n", library-object , name, type, value, size

  • If hexadecimal is specified, or by default:

    "%s%s %s %x %x\n", library-object, name, type, value, size

where library-object is a string preformatted as follows:

  • If -A and -r are not specified, library-object is an empty string.

  • If -A or -r is specified, and the corresponding file operand does not name a library:

    "%s: ", file

  • If -A or -r is specified and the corresponding file operand names a library, object-file names the object file in the library containing the symbol being described:

    "%s[%s]: ", file, object-file

If -A and -r are not specified, and if more than one file operand is specified, or if a single file operand that names a library is specified, then nm prints a line identifying the object containing the symbols before the lines containing those symbols, in one of the following forms:

  • If the corresponding file operand does not name a library:

    "%s:\n", file

  • If the corresponding file operand names a library, object-file names the object file in the library containing the symbol being described:

    "%s[%s]:\n", file, object-file

EXTERNAL INFLUENCES

Environment Variables

The following internationalization variables affect the execution of nm:

LANG determines the locale category for native language, local customs and coded character set in the absence of LC_ALL or other LC_* environment variables. If LANG is not specified or is null, it defaults to C (see lang(5)).

LC_ALL, if set to a nonempty string value, determines the values for all locale categories and has precedence over LANG and other LC_* environment variables.

LC_COLLATE determines the locale category for character collation.

LC_CTYPE determines the locale category for character handling functions.

LC_MESSAGES determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

LC_NUMERIC determines the locale category for numeric formatting.

ST_NMCAT and NLSPATH determine the location of message catalogues for processing LC_MESSAGES.

If an internationalization variable is not specified or is null, it defaults to the value of LANG.

If LANG is not specified or is null, it defaults to C (see lang(5)).

If any internationalization variable contains an invalid setting, then all internationalization variables default to C (see environ(5)).

International Code Set Support

Single-byte character code sets are supported.

EXAMPLES

Display which object files have undefined references for the symbol leap:

nm -rup *.o | grep leap

Display which object files have a definition for the text symbol leap:

nm -rp *.o | awk '{ if ($3 == "T" && $4 == "leap") { print $0 } }'

WARNINGS

By default, nm now sorts symbols by name (the -n option). To turn off sorting, use the -N option.

Some options added for standards conformance duplicate the functionality of options that previously existed. This duplication has been retained for backward compatibility.

SEE ALSO

System Tools

cc_bundled(1)

HP-UX C compiler

ld(1)

Link editor

Miscellaneous

crt0(3)

Execution startup routine

end(3C)

Symbol of the last locations in program

STANDARDS CONFORMANCE

nm: SVID2, SVID3, XPG2, XPG3, XPG4

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.