NM(1)
π NM(1) β GNU Development Tools π
okay so bestie, welcome to nm, straight out of the GNU Development Tools manual. it's the tool that spills the tea on every symbol hiding inside your object files, and honestly? iconic. π«Ά
β¨ NAME β¨
nm β list symbols from object files. that's the whole job, no cap. π
πΈ SYNOPSIS πΈ
nm [-A|-o|--print-file-name]
[-a|--debug-syms]
[-B|--format=bsd]
[-C|--demangle[=style]]
[-D|--dynamic]
[-fformat|--format=format]
[-g|--extern-only]
[-h|--help]
[--ifunc-chars=CHARS]
[-j|--format=just-symbols]
[-l|--line-numbers] [--inlines]
[-n|-v|--numeric-sort]
[-P|--portability]
[-p|--no-sort]
[-r|--reverse-sort]
[-S|--print-size]
[-s|--print-armap]
[-t radix|--radix=radix]
[-u|--undefined-only]
[-U|--defined-only]
[-V|--version]
[-W|--no-weak]
[-X 32_64]
[--no-demangle]
[--no-recurse-limit|--recurse-limit]]
[--plugin name]
[--size-sort]
[--special-syms]
[--synthetic]
[--target=bfdname]
[--unicode=method]
[--with-symbol-versions]
[--without-symbol-versions]
[objfile...]
π DESCRIPTION π
GNU nm lists the symbols from object files objfile.... And if you don't hand it any object files as arguments at all? it just assumes the file a.out. bold move, honestly. π
So for each symbol, nm shows you this whole little lineup:
- The symbol value, in the radix selected by options (see below), or hexadecimal by default.
- The symbol type. At least the following types are used; others are, as well, depending on the object file format. If lowercase, the symbol is usually local; if uppercase, the symbol is global (external). There are however a few lowercase symbols that are shown for special global symbols (
u,vandw). πAβ the symbol's value is absolute, and will not be changed by further linking. locked in forever, fr fr.B,bβ the symbol is in the BSS data section. this section typically contains zero-initialized or uninitialized data, although the exact behavior is system dependent. πC,cβ the symbol is common. common symbols are uninitialized data. when linking, multiple common symbols may appear with the same name. if the symbol is defined anywhere, the common symbols are treated as undefined references. and the lowercaseccharacter is used when the symbol is in a special section for small commons.D,dβ the symbol is in the initialized data section. β¨G,gβ the symbol is in an initialized data section for small objects. some object file formats permit more efficient access to small data objects, such as a global int variable as opposed to a large global array. efficiency slay.iβ for PE format files this indicates that the symbol is in a section specific to the implementation of DLLs.
For ELF format files this indicates that the symbol is an indirect function. this is a GNU extension to the standard set of ELF symbol types. it indicates a symbol which if referenced by a relocation does not evaluate to its address, but instead must be invoked at runtime. the runtime execution will then return the value to be used in the relocation.
Note β the actual symbols display for GNU indirect symbols is controlled by the --ifunc-chars command line option. If this option has been provided then the first character in the string will be used for global indirect function symbols. If the string contains a second character then that will be used for local indirect function symbols.
Iβ the symbol is an indirect reference to another symbol. it's giving "i know a guy" π«ΆNβ the symbol is a debugging symbol. πnβ the symbol is in a non-data, non-code, non-debug read-only section.pβ the symbol is in a stack unwind section.R,rβ the symbol is in a read only data section.S,sβ the symbol is in an uninitialized or zero-initialized data section for small objects.T,tβ the symbol is in the text (code) section. main character energy tbh.Uβ the symbol is undefined. it's not lost, it's just... elsewhere. πuβ the symbol is a unique global symbol. this is a GNU extension to the standard set of ELF symbol bindings. for such a symbol the dynamic linker will make sure that in the entire process there is just one symbol with this name and type in use. one of one, periodt.V,vβ the symbol is a weak object. when a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. when a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error. on some systems, uppercase indicates that a default value has been specified.W,wβ the symbol is a weak symbol that has not been specifically tagged as a weak object symbol. when a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. when a weak undefined symbol is linked and the symbol is not defined, the value of the symbol is determined in a system-specific manner without error. on some systems, uppercase indicates that a default value has been specified.-β the symbol is a stabs symbol in an a.out object file. in this case, the next values printed are the stabs other field, the stabs desc field, and the stab type. stabs symbols are used to hold debugging information.?β the symbol type is unknown, or object file format specific. the mystery era. π
- The symbol name. and if a symbol has version information associated with it, then the version information is displayed as well. if the versioned symbol is undefined or hidden from linker, the version string is displayed as a suffix to the symbol name, preceded by an
@character. for examplefoo@VER_1. and if the version is the default version to be used when resolving unversioned references to the symbol, then it is displayed as a suffix preceded by two@characters. for examplefoo@@VER_2. π
β¨ OPTIONS β¨
Okay bestie, here's the tea: the long forms and the short forms are literally the same thing. Pick whichever one vibes with you. π
-A,-o,--print-file-nameβ puts the name of the input file (or the archive member) right before each symbol, instead of just naming the file once at the top before all its symbols. So you always know exactly who's who. π«Ά-a,--debug-symsβ shows all the symbols, even the debugger-only ones. Normally those get left out of the party. π-Bβ same as--format=bsd(it's there so it plays nice with the MIPSnm). Legacy behaviour, still iconic.-C,--demangle[=style]β decodes (demangles) those cursed low-level symbol names into actual user-level names. Besides stripping any leading underscore the system slapped on there, it makes C++ function names readable to humans. Different compilers use different mangling styles, so the optional style argument lets you pick the right demangling style for your compiler. so helpful fr fr--no-demangleβ don't demangle anything. This is the default, bestie.--recurse-limit,--no-recurse-limit,--recursion-limit,--no-recursion-limitβ turns a limit on recursion during demangling on or off. Here's the why: name mangling formats allow infinite recursion, so somebody could craft strings whose decoding eats up all your stack space and triggers a memory fault. π The limit tries to stop that by capping recursion at 2048 levels of nesting.
The default is for the limit to be enabled, but you might need to disable it to demangle truly complicated names. That said β if you turn the recursion limit off, stack exhaustion is possible, and any bug reports about that will be rejected. You've been warned, gorgeous. π«
-D,--dynamicβ shows the dynamic symbols instead of the normal ones. Only meaningful for dynamic objects, like certain types of shared libraries.-fformat,--format=format β use output format format, which can be"bsd","sysv","posix"or"just-symbols". Default is"bsd". Only the first character of format matters, and it can be upper or lower case. slay, minimal effort.-g,--extern-onlyβ only external symbols, nothing else invited.-h,--helpβ shows a summary of the options fornmand dips. π--ifunc-chars=CHARSβ when showing GNU indirect function symbols,nmdefaults to the"i"character for both local and global indirect functions. This option lets you specify a string with one or two characters. The first character is used for global indirect function symbols, and the second (if present) is used for local indirect function symbols. cute and customisable. πjβ same as--format=just-symbols.-l,--line-numbersβ for each symbol, use debugging info to try to find a filename and line number. For a defined symbol, look for the line number of the symbol's address. For an undefined symbol, look for the line number of a relocation entry that refers to the symbol. If line number info turns up, it gets printed after the other symbol info.--inlinesβ when-lis active, if the address belongs to a function that got inlined, this makes the source info for all enclosing scopes back to the first non-inlined function print too. For example, if"main"inlines"callee1"which inlines"callee2", and the address is from"callee2", then the source info for"callee1"and"main"also gets printed. nesting reveal!!-n,-v,--numeric-sortβ sorts symbols numerically by their addresses instead of alphabetically by their names.-p,--no-sortβ doesn't bother sorting at all, just prints them in the order they were encountered. chaos mode, lowkey valid. β¨-P,--portabilityβ uses the POSIX.2 standard output format instead of the default. Equivalent to-f posix.-r,--reverse-sortβ flips the sort order (numeric or alphabetic either way); the last shall come first. π-S,--print-sizeβ prints both the value and the size of defined symbols for the"bsd"output style. This has no effect for object formats that don't record symbol sizes β unless--size-sortis also used, in which case a calculated size is displayed.-s,--print-armapβ when listing symbols from archive members, includes the index: a mapping (stored in the archive byarorranlib) of which modules contain definitions for which names.-tradix,--radix=radix β use radix as the radix for printing symbol values. It must bedfor decimal,ofor octal, orxfor hexadecimal. no other options babe.-u,--undefined-onlyβ only undefined symbols (the ones external to each object file). By default, both defined and undefined symbols are shown.-U,--defined-onlyβ only defined symbols for each object file. Again, default is both defined and undefined.-V,--versionβ shows the version number ofnmand exits. π«‘-Xβ this option is ignored, kept for compatibility with the AIX version ofnm. It takes one parameter which must be the string32_64. The default mode of AIXnmcorresponds to-X 32, which is not supported by GNUnm. so... yeah. it's giving decoration.--pluginname β loads the plugin called name to add support for extra target types. This option is only available if the toolchain was built with plugin support enabled.
If --plugin isn't provided but plugin support is enabled, then nm iterates over the files in ${libdir}/bfd-plugins in alphabetic order and the first plugin that claims the object in question gets used.
Please note: this plugin search directory is not the one used by ld's -plugin option. To make nm use the linker plugin, it must be copied into the ${libdir}/bfd-plugins directory. For GCC-based compilations the linker plugin is called liblto_plugin.so.0.0.0. For Clang-based compilations it's called LLVMgold.so. The GCC plugin is always backwards compatible with earlier versions, so just copying the newest one is sufficient. π§
--size-sortβ sorts symbols by size. For ELF objects, symbol sizes are read from the ELF; for other object types, sizes are computed as the difference between the symbol's value and the value of the symbol with the next higher value. If the"bsd"output format is used, the size of the symbol is printed rather than the value, and-Smust be used for both size and value to print.
Heads up β this option does not work if --undefined-only has been enabled, because undefined symbols have no size. can't measure what isn't there bestie π
--special-symsβ displays symbols with a target-specific special meaning. These are usually used by the target for some special processing and aren't normally helpful in normal symbol lists. For example, for ARM targets this option would skip the mapping symbols used to mark transitions between ARM code, THUMB code and data.--syntheticβ includes synthetic symbols in the output. These are special symbols created by the linker for various purposes. They're not shown by default since they aren't part of the binary's original source code. π--unicode=[default|invalid|locale|escape|hex|highlight]β controls how UTF-8 encoded multibyte characters are displayed in strings. The default (--unicode=default) gives them no special treatment.--unicode=localedisplays the sequence in the current locale, which may or may not support them.--unicode=hexand--unicode=invaliddisplay them as hex byte sequences enclosed by either angle brackets or curly braces.
--unicode=escape displays them as escape sequences (\uxxxx), and --unicode=highlight displays them as escape sequences highlighted in red (if the output device supports it). The colouring is meant to draw attention to unicode sequences where you might not expect them. π
-W,--no-weakβ doesn't display weak symbols.--with-symbol-versions,--without-symbol-versionsβ enables or disables the display of symbol version info. The version string shows up as a suffix on the symbol name, preceded by an@character. For examplefoo@VER_1. If the version is the default version used when resolving unversioned references to the symbol, then it's displayed as a suffix preceded by two@characters. For examplefoo@@VER_2. By default, symbol version info is displayed.--target=bfdname β specify an object code format other than your system's default format.@file β read command-line options from file. The options read get inserted in place of the original@file option. If file doesn't exist, or can't be read, then the option is treated literally and not removed.
Options in file are separated by whitespace. A whitespace character can be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) can be included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options get processed recursively. π
πΈ SEE ALSO πΈ
ar(1), objdump(1), ranlib(1), and the Info entries for binutils. go read those next, i'm literally begging π«Ά
π COPYRIGHT π
Copyright (c) 1991-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
and that's the whole page bestie!! π this edition is from binutils-2.40.50, dated 2023-07-04, and it's NM(1) β now go run nm on something and feel like the main character you are. periodt. β¨π
π¦
π¦ where this page comes from
- ubuntu noble: binutils-msp430 2.40.50~ti1ubuntu1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms