NM(1)

πŸ“¦
version 2.45.50.20251209+3.5.3build1 Β· 5 versions
, in ubuntu resolute, ubuntu stonking

nm β€” list symbols from object files πŸ’…βœ¨

GNU Development Tools Β· NM(1)


NAME πŸŽ€

nm β€” bestie, it lists symbols from object files. That's the whole vibe. Periodt.


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 🌸

Okay so, GNU nm lists the symbols from object files objfile…. Iconic behavior. And if you don't hand it any object files as arguments at all? It just assumes the file a.out. No cap, it's that confident. πŸ‘‘

For each symbol, nm shows you three things, and here they are:

  • The symbol value, in the radix selected by options (see below), or hexadecimal by default.
  • The symbol type. At least the following types get used β€” others do too, depending on the object file format. Here's the little rule that matters: if it's lowercase, the symbol is usually local; if it's uppercase, the symbol is global (external). But bestie, there are a few lowercase symbols that get shown for special global symbols ("u", "v" and "w"). Not me calling out the exceptions. πŸ™ˆ
    • "A" β€” the symbol's value is absolute, and further linking will not change it. Locked in 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. The lower case c character 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. Tiny but mighty energy. πŸ“
    • "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.
  • "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.
  • "U" β€” the symbol is undefined.
  • "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. πŸ‘‘
  • "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 symbol name. And here's the tea πŸ«– β€” 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 example foo@VER_1. But 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 example foo@@VER_2. Two at-signs, no cap, that's the whole difference. πŸ’€

<div align="center">✨ <em>to be continued…</em> ✨</div>

✨ OPTIONS ✨

okay bestie so the long form and the short form of every option here are literally the same thing, they're just listed as alternatives πŸ’… pick whichever, they're equivalent, periodt.

  • -A, -o, --print-file-name β€” puts the name of the input file (or the archive member, if that's what we're looking at) right before each symbol it was found in, instead of just naming the file once up top before all of its symbols. so yeah, way more repetitive, way more precise 🌸
  • -a, --debug-syms β€” shows all the symbols, even the debugger-only ones. normally those little guys get left out of the list entirely.
  • -B β€” same as --format=bsd. it's here for compatibility with the MIPS nm. a lil throwback, we love a legacy moment πŸ’–
  • -C, --demangle[=style] β€” decodes (demangles) those low-level symbol names back into user-level names. besides stripping any initial underscore the system stuck on there, this is what makes C++ function names actually readable instead of a cursed pile of letters. different compilers use different mangling styles, so that optional style argument lets you pick the right demangling style for your compiler πŸŽ€
  • --no-demangle β€” do NOT demangle low-level symbol names. this is the default, so if you do nothing, you get the raw names. feral behaviour, honestly.
  • --recurse-limit, --no-recurse-limit, --recursion-limit, --no-recursion-limit β€” turns the recursion limit for demangling strings on or off. here's the tea: name mangling formats allow for infinite levels of recursion, so it is genuinely possible to build strings whose decoding will eat up all the stack space on your machine and trigger a memory fault 😭 the limit exists to stop that from happening, and it restricts recursion to 2048 levels of nesting.

the default is for this limit to be enabled, but turning it off may be necessary to demangle truly complicated names. BUT. if you disable the recursion limit, stack exhaustion is possible, and any bug reports about that will be rejected. like, straight up refused. so be so serious about that one.

  • -D, --dynamic β€” shows the dynamic symbols instead of the normal symbols. this is only meaningful for dynamic objects, like certain types of shared libraries πŸ¦‹
  • -f format, --format=format β€” use the output format format, which can be "bsd", "sysv", "posix" or "just-symbols". the default is "bsd". only the *first character of *format is significant, and it can be upper or lower case πŸ‘‘
  • -g, --extern-only β€” only external symbols. nothing else, we're being exclusive.
  • -h, --help β€” shows a summary of the options for nm and exits. your little cheat sheet πŸ’œ
  • --ifunc-chars=CHARS β€” when it's displaying GNU indirect function symbols, nm defaults to using the "i" character for both local indirect functions and global indirect functions. this option lets you specify a string containing one or two characters. the **first character gets used for global indirect function symbols, and the second one β€” if there is one β€” gets used for local indirect function symbols 🌈
  • j β€” same as --format=just-symbols. just the symbols, no drama.
  • -l, --line-numbers β€” for each symbol, it uses debugging info to try and find a filename and line number. for a defined symbol, it looks for the line number of the address of the symbol. for an undefined symbol, it looks for the line number of a relocation entry that refers to the symbol. if that line number info can be found, it's printed after the other symbol info πŸŽ€
  • --inlines β€” when -l is active, if the address belongs to a function that got inlined, this makes the source info for all the enclosing scopes get printed too, all the way back to the first non-inlined function. example: if "main" inlines "callee1" which inlines "callee2", and the address is from "callee2", then the source information for "callee1" and "main" gets printed as well. it's giving ancestry.com, but for stack frames 🧚
  • -n, -v, --numeric-sort β€” sorts the 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 encountered. chaos mode, honestly kind of iconic πŸ’…
  • -P, --portability β€” uses the POSIX.2 standard output format instead of the default one. equivalent to -f posix.
  • -r, --reverse-sort β€” flips the order of the sort (whichever sort it is, numeric or alphabetic). last comes first. main character goes last ✨
  • -S, --print-size β€” prints both the value and the size of defined symbols, for the "bsd" output style. heads up: this option has no effect for object formats that don't record symbol sizes β€” unless --size-sort is also used, in which case a calculated size gets displayed.
  • -s, --print-armap β€” when listing symbols from archive members, this includes the index: a mapping (stored in the archive by ar or ranlib) of which modules contain definitions for which names πŸ“š
  • -t radix, --radix=radix β€” uses radix as the radix for printing the symbol values. it **must be d for decimal, o for octal, or x for hexadecimal. those are the only options bestie, don't try anything else πŸ™ˆ
  • -u, --undefined-only β€” only shows undefined symbols (the ones external to each object file). by default, both defined and undefined symbols get displayed.
  • -U, --defined-only β€” only shows defined symbols for each object file. by default, both defined and undefined symbols get displayed.
  • -V, --version β€” shows the version number of nm and exits 🌸
  • -X β€” this option is ignored, for compatibility with the AIX version of nm. it takes one parameter which must be the string 32_64. the default mode of AIX nm corresponds to -X 32, which is not supported by GNU nm. so it's just vibes and backwards compatibility, no actual behaviour πŸ’€
  • *--plugin *name β€” 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 has been 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 that this plugin search directory is not the one used by ld's -plugin option. in order 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 it's sufficient to just copy the newest one 🫢

  • --size-sort β€” sorts symbols by size. for ELF objects, symbol sizes are read from the ELF; for other object types, the symbol sizes are computed as the difference between the value of the symbol 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 -S must be used in order for both size and value to be printed.
note β€” this option does not work if --undefined-only has been enabled, because undefined symbols have no size. they're size-less little ghosts 😭
  • --special-syms β€” displays symbols that have a target-specific special meaning. these symbols are usually used by the target for some special processing and aren't normally helpful when included in the 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. they're the linker's own little OCs πŸ’…
  • --unicode=[default|invalid|locale|escape|hex|highlight] β€” controls how UTF-8 encoded multibyte characters get displayed in strings. the default (--unicode=default) gives them no special treatment at all. the --unicode=locale option displays the sequence in the current locale, which may or may not support them. the --unicode=hex and --unicode=invalid options display them as hex byte sequences, enclosed by either angle brackets or curly braces.

the --unicode=escape option displays them as escape sequences (\uxxxx), and the --unicode=highlight option displays them as escape sequences highlighted in red (if supported by the output device). the colouring is intended to draw attention to the presence of unicode sequences where they might not be expected πŸ‘€

  • -W, --no-weak β€” does not display weak symbols. weak symbols, we don't know her.
  • --with-symbol-versions, --without-symbol-versions β€” enables or disables the display of symbol version information. the version string gets displayed as a suffix to the symbol name, preceded by an @ character. for example foo@VER_1. if the version is the default version to be used when resolving unversioned references to the symbol, then it's displayed as a suffix preceded by two @ characters. for example foo@@VER_2. by default, symbol version information is displayed 🌸
  • *--target=bfdname* β€” specifies an object code format other than your system's default format.
  • @file β€” reads command-line options from file. the options that get read are 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 it is 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, and any such options get processed recursively πŸ¦‹


🌟 SEE ALSO 🌟

ar(1), objdump(1), ranlib(1), and the Info entries for binutils.

go read those too, they're all in the same friend group πŸ’–


Copyright (c) 1991-2025 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, you ate that 🫢 this was binutils-2.45.50, dated 2026-01-13, and it's officially NM(1). go demangle something gorgeous πŸ‘‘βœ¨

πŸ“¦ where this page comes from