Copyright 1989 AT&T
Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
/usr/bin/nm [-ACDhlnPprRsTuVv] [-efox] [-g | -u] [-t format] file...
/usr/xpg4/bin/nm [-ACDhlnPprRsTuVv] [-efox] [-g | -u] [-t format] file...
The nm utility displays the symbol table of each ELF object file that is specified by file.
If no symbolic information is available for a valid input file, the nm utility reports that fact, but not consider it an error condition.
The output of nm can be controlled using the following options: -A
Writes the full path name or library name of an object on each line.
Demangles C++ symbol names before printing them out.
Displays the SHT_DYNSYM symbol information. This is the symbol table used by ld.so.1 and is present even in stripped dynamic executables. If -D is not specified, the default behavior is to display the SHT_SYMTAB symbol information.
See NOTES below.
See NOTES below.
Writes only external (global) symbol information.
Does not display the output heading data.
Displays the SHT_SUNW_LDYNSYM symbol information. This symbol table contains local function symbols. SHT_SUNW_LDYNSM symbol tables are present even in stripped dynamic executables. These symbols augment the global symbols that are found in SHT_DYNSYM symbol table. If -L is not specified, the default behavior is to display the SHT_SYMTAB symbol information.
Distinguishes between WEAK and GLOBAL symbols by appending a * to the key letter for WEAK symbols.
Sorts external symbols by name before they are printed.
Prints the value and size of a symbol in octal instead of decimal (equivalent to -t o).
Produces easy to parse, terse output. Each symbol name is preceded by its value (blanks if undefined) and one of the letters: A
Absolute symbol.
bss (uninitialized data space) symbol.
COMMON symbol.
Data object symbol.
File symbol.
Symbol has no type.
Thread-Local storage symbol.
Section symbol.
Text symbol.
Undefined.
The key letter is lower case.
The key letter is upper case. If the -l modifier is specified, the upper case key letter is followed by a *
The key letter is upper case.
Writes information in a portable output format, as specified in Standard Output.
Prepends the name of the object file or archive to each output line.
Prints the archive name (if present), followed by the object file and symbol name. If the -r option is also specified, this option is ignored.
Prints section name instead of section index.
Writes each numeric value in the specified format. The format is dependent on the single character used as the format option-argument: d
The offset is written in decimal (default).
The offset is written in octal.
The offset is written in hexadecimal.
See NOTES.
Prints undefined symbols only.
Prints long listing for each undefined symbol. See OUTPUT below.
Sorts external symbols by value before they are printed.
Prints the version of the nm command executing on the standard error output.
Prints the value and size of a symbol in hexadecimal instead of decimal (equivalent to -t x).
Options can be used in any order, either singly or in combination, and can appear anywhere in the command line. When conflicting options are specified (such as -v and -n, or -o and -x) the first is taken and the second ignored with a warning message to the user. (See -R for exception.)
The following operand is supported: file
A path name of an object file, executable file or object-file library.
This section describes the nm utility's output options.
For each symbol, the following information is printed: Index
The index of the symbol. (The index appears in brackets.)
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.
The size in bytes of the associated object.
A symbol is of one of the following types: NOTYPE
No type was specified.
A data object such as an array or variable.
A function or other executable code.
A register symbol (SPARC only).
A section symbol.
Name of the source file.
An uninitialized common block.
A variable associated with Thread-Local storage.
The symbol's binding attributes. LOCAL symbols
Have a scope limited to the object file containing their definition.
Are visible to all object files being combined.
Are essentially global symbols with a lower precedence than GLOBAL.
A symbol's visibility. The lower bits of the st_other member of the Elf32_Sym structure, and the Elf64_Sym structure, defined in <sys/elf.h>, are currently used and can be one of:
#define STV_DEFAULT 0 #define STV_INTERNAL 1 #define STV_HIDDEN 2 #define STV_PROTECTED 3 #define STV_EXPORTED 4 #define STV_SINGLETON 5 #define STV_ELIMINATE 6
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 does not change through relocation.
Indicates an unallocated block and the value provides alignment constraints.
Indicates an undefined symbol.
The name of the symbol.
The name of the object or library if -A is specified.
If the -P option is specified, the previous information is displayed using the following portable format. The three versions differ depending on whether -t d, -t o, or -t x was specified, respectively:
"%s%s %s %d %d\n", library/object name, name, type, value, \e size "%s%s %s %o %o\n", library/object name, name, \e type, value , size "%s%s %s %x %x\n", library/object name, name, \e type, value, size
where library/object name is formatted as follows:
If -A is specified and the corresponding file operand does not name a library:
"%s: ", file
If -A is specified and the corresponding file operand names a library. In this case, object file names the object file in the library containing the symbol being described:
"%s[%s]: ", file, object file
If -A is not specified, then if more than one file operand is specified or if only one file operand is specified and it names a library, nm writes a line identifying the object containing the following symbols before the lines containing those symbols, in the form:
If the corresponding file operand does not name a library:
"%s:\n", file
If the corresponding file operand names a library; in this case, object file is the name of the file in the library containing the following symbols:
"%s[%s]:\n", file, object file
If -P is specified, but -t is not, the format is as if -t x had been specified.
See environ(5) for descriptions of the following environment variables that affect the execution of nm: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned: 0
Successful completion.
An error occurred.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability Committed |
ar(1), as(1), dump(1), ld(1), ld.so.1(1), ar.h(3HEAD), a.out(4), attributes(5), environ(5), standards(5)
The following options are obsolete because of changes to the object file format and might be deleted in a future release. -e
Prints 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, which can be examined using dump(1).
Produces full output. Redundant symbols (such as .text, .data, and so forth), which existed previously, do not exist and producing full output is identical to the default output.
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.