|NM(1P)||POSIX Programmer's Manual||NM(1P)|
nm [-APv] [-g|-u] [-t format] file... nm [-APv] [-efox] [-g|-u] [-t format] file...
The default base used when numeric values are written is unspecified. On XSI-conformant systems, it shall be decimal if the -P option is not specified.
The following options shall be supported:
- Write the full pathname or library name of an object on each line.
- Write only external (global) and static symbol information.
- Produce full output. Write redundant symbols (.text, .data, and .bss), normally suppressed.
- Write only external (global) symbol information.
- Write numeric values in octal (equivalent to -t o).
- Write information in a portable output format, as specified in the STDOUT section.
- -t format
- Write each numeric value in the specified format. The format shall be dependent on the single character used as the format option-argument:
- decimal (default if -P is not specified).
- hexadecimal (default if -P is specified).
- Write only undefined symbols.
- Sort output by value instead of by symbol name.
- Write numeric values in hexadecimal (equivalent to -t x).
- A pathname of an object file, executable file, or object-file library.
- Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1‐2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
- If set to a non-empty string value, override the values of all the other internationalization variables.
Determine the locale for character collation information for the symbol-name and symbol-value collation sequences.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogs for the processing of LC_MESSAGES.
- Library or object name, if -A is specified
- Symbol name
- Symbol type, which shall either be one of the following single characters or an implementation-defined type represented by a single character:
- Global absolute symbol.
- Local absolute symbol.
- Global ``bss'' (that is, uninitialized data space) symbol.
- Local bss symbol.
- Global data symbol.
- Local data symbol.
- Global text symbol.
- Local text symbol.
- Undefined symbol.
- Value of the symbol
- The size associated with the symbol, if applicable
This information may be supplemented by additional information specific to the implementation.
If the -P option is specified, the previous information shall be 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>, <size>
"%s%s %s %o %o\n", <library/object name>, <name>, <type>, <value>, <size>
"%s%s %s %x %x\n", <library/object name>, <name>, <type>, <value>, <size>
where <library/object name> shall be formatted as follows:
- If -A is not specified, <library/object name> shall be an empty string.
- 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> shall name 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 shall write 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:
- If the corresponding file operand names a library; in this case, <object file> shall be 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 shall be as if -t x had been specified.
- Successful completion.
- An error occurred.
The following sections are informative.
The compromise of using -t format versus using -d, -o, and other similar options was necessary because of differences in the meaning of -o between implementations. The -o option from BSD has been provided here as -A to avoid confusion with the -o from System V (which has been provided here as -t and as -o on XSI-conformant systems).
The option list was significantly reduced from that provided by historical implementations.
The nm description is a subset of both the System V and BSD nm utilities with no specified default output.
It was recognized that mechanisms for dynamic linking make this utility less meaningful when applied to an executable file (because a dynamically linked executable file may omit numerous library routines that would be found in a statically linked executable file), but the value of nm during software development was judged to outweigh other limitations.
The default output format of nm is not specified because of differences in historical implementations. The -P option was added to allow some type of portable output format. After a comparison of the different formats used in SunOS, BSD, SVR3, and SVR4, it was decided to create one that did not match the current format of any of these four systems. The format devised is easy to parse by humans, easy to parse in shell scripts, and does not need to vary depending on locale (because no English descriptions are included). All of the systems currently have the information available to use this format.
The format given in nm STDOUT uses <space> characters between the fields, which may be any number of <blank> characters required to align the columns. The single-character types were selected to match historical practice, and the requirement that implementation additions also be single characters made parsing the information easier for shell scripts.
The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|2017||IEEE/The Open Group|