NM(1P)
π NM β the POSIX bestie page π
okay so hi bestie π«Ά welcome to nm(1P), straight out of the POSIX Programmer's Manual. it's giving "let me read your object file's whole aura" β¨
πΈ PROLOG πΈ
so like, heads up before we even start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so pls consult the corresponding Linux manual page for the tea on Linux behavior β), or honestly the interface may just not be implemented on Linux at all. no cap. π
β¨ NAME β¨
nm β write the name list of an object file (DEVELOPMENT) π
π SYNOPSIS π
nm [-APv] [-g|-u] [-t format] file...
nm [-APv] [-efox] [-g|-u] [-t format] file...
look at her. two whole forms. iconic. π
π¦ DESCRIPTION π¦
okay so the nm utility shall display symbolic information appearing in the object file, executable file, or object-file library named by file. literally it's the gossip column for your binaries π
if no symbolic information is available for a valid input file, nm shall report that fact, but β important β it shall not consider it an error condition. so like, it's not mad at you, it's just saying "nothing to see here bestie" π
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. iykyk.
π OPTIONS π
the nm utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. periodt. π
the following options shall be supported:
-Aβ write the full pathname or library name of an object on each line. every line gets the receipts π§Ύ-eβ write only external (global) and static symbol information. the VIPs only.-fβ produce full output. write redundant symbols (.text,.data, and.bss), normally suppressed. the "give me EVERYTHING" option π-gβ write only external (global) symbol information. just the globals, bestie.-oβ write numeric values in octal (equivalent to-t o). 8οΈβ£-Pβ write information in a portable output format, as specified in the STDOUT section. the travel-friendly format βοΈ-tformat β write each numeric value in the specified format. the format shall be dependent on the single character used as the format option-argument:dβ decimal (default if-Pis not specified).oβ octal.xβ hexadecimal (default if-Pis specified).
-uβ write only undefined symbols. the mysterious ones π»-vβ sort output by value instead of by symbol name. chaotic but valid.-xβ write numeric values in hexadecimal (equivalent to-t x). π₯
π§ OPERANDS π§
the following operand shall be supported:
- file β a pathname of an object file, executable file, or object-file library.
that's it. one operand. we love a low-maintenance queen π
π STDIN π
see the INPUT FILES section. go look, bestie π
π INPUT FILES π
the input file shall be an object file, an object-file library whose format is the same as those produced by the ar utility for link editing, or an executable file. the nm utility may accept additional implementation-defined object library formats for the input file. so like, it's flexible. we stan adaptability. π¦
π ENVIRONMENT VARIABLES π
the following environment variables shall affect the execution of nm:
LANGβ 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.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables. she overrides. she's the main character. πLC_COLLATEβ determine the locale for character collation information for the symbol-name and symbol-value collation sequences.LC_CTYPEβ 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).LC_MESSAGESβ determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ determine the location of message catalogs for the processing ofLC_MESSAGES.
β ASYNCHRONOUS EVENTS β
default. simple. elegant. nothing to report π
π STDOUT π
okay bestie this is the big one, stay with me π«Ά
if symbolic information is present in the input files, then for each file or for each member of an archive, the nm utility shall write the following information to standard output. by default, the format is unspecified, but the output shall be sorted by symbol name according to the collation sequence in the current locale.
- library or object name, if
-Ais 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:
Aβ global absolute symbol.aβ local absolute symbol.Bβ global ``bss'' (that is, uninitialized data space) symbol.bβ local bss symbol.Dβ global data symbol.dβ local data symbol.Tβ global text symbol.tβ local text symbol.Uβ 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
-Ais not specified,<library/object name>shall be an empty string. - if
-Ais specified and the corresponding file operand does not name a library:
"%s: ", <file>
- if
-Ais 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:
"%s:\n", <file>
- 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. sneaky default, love that for her π
πΈ STDERR πΈ
the standard error shall be used only for diagnostic messages. that's her only job, and she does it well π
π OUTPUT FILES π
none. zero. nada. she doesn't write files, she writes to you π«Ά
π¦ EXTENDED DESCRIPTION π¦
none. moving on bestie πβοΈ
π EXIT STATUS π
the following exit values shall be returned:
0β successful completion. slay π>0β an error occurred. rip π
π CONSEQUENCES OF ERRORS π
default. (and like, the following sections are informative. just so you know. π)
π APPLICATION USAGE π
mechanisms for dynamic linking make this utility less meaningful when applied to an executable file because a dynamically linked executable may omit numerous library routines that would be found in a statically linked executable. so like, nm on a dynamic binary is giving "where did everyone go" π
β EXAMPLES β
none. (sad, i know. no demo for us today π)
π RATIONALE π
okay this is the "why is she like this" section, and honestly it's fascinating, buckle up π’
historical implementations of nm have used different bases for numeric output and supplied different default types of symbols that were reported. the -t format option, similar to that used in od and strings, can be used to specify the numeric base; -g and -u can be used to restrict the amount of output or the types of symbols included in the output.
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. (glow-down, honestly.)
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. teamwork makes the dream work fr fr π«Ά
π§ FUTURE DIRECTIONS π§
none. the future is a mystery and honestly that's fine π
π SEE ALSO π
ar, c99
the Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version 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 .
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 .
and that's the whole page bestie!! πβ¨ brought to you by IEEE/The Open Group, dated 2017 β the NM(1P) era. she ate and left no crumbs π
π stay iconic, go read your object files π¦π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms