NM(1)

๐Ÿ“ฆ version 2.45, in ubuntu questing

๐ŸŽ€ nm(1) ๐ŸŽ€

GNU Development Tools ๐Ÿ’œ

๐Ÿฆ‹ NAME ๐Ÿฆ‹

nm - list symbols from object files โœจ

๐Ÿ’– 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... ๐Ÿซถ If you don't pass any object files as arguments, nm just assumes you mean the file a.out ๐ŸŒธ

For each symbol, nm shows:

  • ๐Ÿ“ The symbol value, in the radix selected by options (see below), or hexadecimal by default.
  • ๐Ÿ”ฅ The symbol type. These are the main ones; others can show up too, depending on the object file format. If it's lowercase, the symbol is usually local. If it's uppercase, the symbol is global (external). There are a few lowercase ones that get shown for special global symbols too ("u", "v" and "w") ๐Ÿ‘€
    • โœจ "A" โ€” The symbol's value is absolute, and further linking won't change it.
    • ๐Ÿ’œ "B" or "b" โ€” The symbol is in the BSS data section. This section usually holds zero-initialized or uninitialized data, although the exact behavior is system dependent.
    • ๐ŸŒˆ "C" or "c" โ€” The symbol is common. Common symbols are uninitialized data. When linking, multiple common symbols can show up with the same name. If the symbol is defined anywhere, the common symbols get treated as undefined references. The lowercase c shows up when the symbol is in a special section for small commons.
    • ๐Ÿฆ‹ "D" or "d" โ€” The symbol is in the initialized data section.
    • ๐Ÿงš "G" or "g" โ€” The symbol is in an initialized data section for small objects. Some object file formats let you access small data objects more efficiently, like a global int versus a big global array.
    • ๐Ÿ’– "i" โ€” For PE format files, this means the symbol is in a section specific to the implementation of DLLs.

For ELF format files, this means the symbol is an indirect function. This is a GNU extension to the standard set of ELF symbol types. It means a symbol that, if referenced by a relocation, doesn't evaluate to its address. Instead, it has to be invoked at runtime, and the runtime execution hands back the value to be used in the relocation.

Note: the actual symbol display for GNU indirect symbols is controlled by the --ifunc-chars command line option. If that option is provided, the first character in the string is used for global indirect function symbols. If the string has a second character, that one is 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" or "r" โ€” The symbol is in a read only data section.
  • ๐Ÿ“ "S" or "s" โ€” The symbol is in an uninitialized or zero-initialized data section for small objects.
  • ๐Ÿ‘‘ "T" or "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 this kind of symbol, the dynamic linker makes sure there's just one symbol with this name and type in use across the entire process.
  • ๐ŸŽ€ "V" or "v" โ€” The symbol is a weak object. When a weak defined symbol gets linked with a normal defined symbol, the normal defined one is used, no error. When a weak undefined symbol is linked and the symbol isn't defined, the value of the weak symbol becomes zero, no error. On some systems, uppercase means a default value has been specified.
  • ๐ŸŒท "W" or "w" โ€” The symbol is a weak symbol that hasn't been specifically tagged as a weak object symbol. When a weak defined symbol gets linked with a normal defined symbol, the normal defined one is used, no error. When a weak undefined symbol is linked and the symbol isn't defined, the value of the symbol is determined in a system-specific manner, no error. On some systems, uppercase means 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 specific to the object file format.
  • ๐Ÿฉท The symbol name. If a symbol has version information attached, that version info gets displayed too. If the versioned symbol is undefined or hidden from the linker, the version string shows up as a suffix on the symbol name, preceded by an @ character, like foo@VER_1. If the version is the default one used when resolving unversioned references to the symbol, it shows up as a suffix preceded by two @ characters, like foo@@VER_2 โœจ

โœจ OPTIONS โœจ

okay so the long and short forms of every option are basically the same thing, bestie ๐Ÿ’– use whichever one you vibe with more

  • -A, --print-file-name โ€” slap the name of the input file (or archive member) where each symbol was found in front of it, instead of naming the file once up top before all the symbols ๐Ÿ“
  • -a, --debug-syms โ€” show all symbols, even the debugger-only ones that nm normally hides from you ๐Ÿ™ˆ
  • -B โ€” same as --format=bsd, which is there so it plays nice with the MIPS nm ๐ŸŽ€
  • -C, --demangle[=style] โ€” decode the messy low-level symbol names into human-readable ones ๐Ÿช„ it strips the extra underscore the system sticks on the front and makes C++ function names actually readable. Different compilers mangle names in different ways, so the optional style argument lets you pick the one that matches your compiler ๐Ÿ’…
  • --no-demangle โ€” leave the low-level symbol names alone. this is the default, so you only need this one if you're explicitly undoing a -C ๐Ÿ’€
  • --recurse-limit, --no-recurse-limit, --recursion-limit, --no-recursion-limit โ€” turn the recursion limit on or off while demangling ๐ŸŒธ the mangling formats technically allow infinite nesting, so some strings can eat up all the stack space on the host machine and cause a memory fault. the limit stops that by capping recursion at 2048 levels of nesting
    • the limit is on by default, but you might need to turn it off to demangle truly complicated names
    • > โš ๏ธ if you disable the recursion limit, stack exhaustion is possible, and any bug reports about that event will be rejected. no cap, be careful!
  • -D, --dynamic โ€” show the dynamic symbols instead of the normal ones โœจ this only matters for dynamic objects, like certain kinds of shared libraries
  • -f format, --format=format โ€” pick the output format. it can be "bsd", "sysv", "posix" or "just-symbols", and the default is "bsd" ๐Ÿฆ‹ only the first character of format actually matters, and it's case-insensitive, so upper or lower both work
  • -g, --extern-only โ€” only show external symbols ๐ŸŒˆ
  • -h, --help โ€” show a quick summary of nm's options, then exit ๐Ÿงš
  • --ifunc-chars=CHARS โ€” customise the characters used for GNU indirect function symbols. by default nm uses "i" for both local and global indirect functions ๐Ÿ’œ this option takes a string of one or two characters. the first is used for global indirect function symbols, and the second (if you give one) is used for local indirect function symbols
  • j โ€” same as --format=just-symbols ๐Ÿ“
  • -l, --line-numbers โ€” use debugging info to figure out a filename and line number for each symbol ๐Ÿ” for a defined symbol, it looks up the line number of the symbol's address. for an undefined symbol, it looks for the line number of a relocation entry that refers to the symbol. if it finds line number info, it prints that after the rest of the symbol info
  • --inlines โ€” only does something when -l is on ๐Ÿ’… if the address belongs to an inlined function, this makes nm also print source info for every enclosing scope, all the way back to the first non-inlined function. for example, if "main" inlines "callee1" which inlines "callee2", and the address is from "callee2", you'll also get the source info for "callee1" and "main" ๐Ÿ‘‘
  • -n, -v, --numeric-sort โ€” sort symbols by their addresses, numerically, instead of alphabetically by name ๐Ÿ”ข
  • -p, --no-sort โ€” don't sort at all, just print the symbols in the order nm encounters them ๐Ÿ™ƒ
  • -P, --portability โ€” use the POSIX.2 standard output format instead of the default one. this is the same as -f posix ๐Ÿ“œ
  • -r, --reverse-sort โ€” flip the sort order, whether it's numeric or alphabetical, so the last one comes first ๐Ÿ”„
  • -S, --print-size โ€” for the "bsd" output style, print both the value and the size of defined symbols โœจ this does nothing for object formats that don't record symbol sizes, unless you also use --size-sort, in which case a calculated size gets shown
  • -s, --print-armap โ€” when listing symbols from archive members, also include the index ๐Ÿ—‚๏ธ that's the mapping (stored in the archive by ar or ranlib) showing which modules define which names
  • -t radix, --radix=radix โ€” choose the radix for printing symbol values. it has to be d for decimal, o for octal, or x for hexadecimal ๐ŸŽ€
  • -u, --undefined-only โ€” only show undefined symbols, the ones that are external to each object file ๐Ÿซถ by default you get both defined and undefined symbols
  • -U, --defined-only โ€” only show defined symbols for each object file ๐Ÿ’– by default you get both defined and undefined symbols
  • -V, --version โ€” show nm's version number and exit ๐ŸŒŸ
  • -X โ€” ignored, just there for compatibility with the AIX version of nm ๐Ÿ™ˆ it takes one parameter, which has to be the string 32_64. the default mode of AIX nm is -X 32, which GNU nm doesn't support
  • --plugin name โ€” load the plugin called name to add support for extra target types ๐Ÿ”Œ this is only available if the toolchain was built with plugin support enabled
    • if you don't give --plugin but plugin support is enabled, nm checks the files in ${libdir}/bfd-plugins in alphabetical order, and the first plugin that claims the object gets used ๐Ÿช„
    • heads up, bestie: this plugin search directory is not the one ld's -plugin option uses ๐Ÿ™…โ€โ™€๏ธ for nm to use the linker plugin, you have to copy it into the ${libdir}/bfd-plugins directory. for GCC-based compilations, the linker plugin is called liblto_plugin.so.0.0.0, and for Clang-based compilations it's called LLVMgold.so. the GCC plugin is always backwards compatible with earlier versions, so copying just the newest one is enough ๐Ÿ’œ
  • --size-sort โ€” sort symbols by size ๐Ÿ“ for ELF objects, the sizes get read straight from the ELF. for other object types, the size is computed as the difference between the symbol's value and the value of the next-higher symbol. if you use the "bsd" output format, the size gets printed instead of the value, so you need -S if you want both size and value
    • > ๐Ÿ“ note: this doesn't work if --undefined-only is enabled, because undefined symbols have no size
  • --special-syms โ€” show symbols that have a target-specific special meaning ๐Ÿงš these are usually used by the target for special processing and aren't normally helpful in the regular lists. for example, on ARM targets this option would skip the mapping symbols that mark transitions between ARM code, THUMB code and data
  • --synthetic โ€” include synthetic symbols in the output ๐Ÿ› ๏ธ these are special symbols the linker creates for various purposes. they're hidden by default, since they aren't part of the binary's original source code
  • --unicode=[default|invalid|locale|escape|hex|highlight] โ€” control how UTF-8 encoded multibyte characters show up in strings ๐ŸŒ
    • --unicode=default is the default, and gives them no special treatment
    • --unicode=locale displays the sequence in the current locale, which may or may not support them
    • --unicode=hex and --unicode=invalid display them as hex byte sequences wrapped in either angle brackets or curly braces
    • --unicode=escape displays them as escape sequences like \uxxxx
    • --unicode=highlight displays them as escape sequences highlighted in red, if your output device supports it ๐Ÿ”ด the colouring is there to draw attention to unicode sequences where you might not expect them
  • -W, --no-weak โ€” don't display weak symbols ๐Ÿ™…โ€โ™€๏ธ
  • --with-symbol-versions, --without-symbol-versions โ€” turn symbol version info on or off ๐Ÿ”– the version string shows up as a suffix on the symbol name, preceded by an @ character, like foo@VER_1. if it's the default version used when resolving unversioned references to the symbol, it's shown with two @ characters instead, like foo@@VER_2. symbol version info is displayed by default
  • --target=bfdname โ€” pick an object code format other than your system's default ๐ŸŽฏ
  • @file โ€” read command-line options from file ๐Ÿ“„ the options it reads get inserted right where the original @file option was. if file doesn't exist or can't be read, the option gets treated literally and isn't removed
    • options inside the file are separated by whitespace. to include a whitespace character in an option, wrap the whole option in single or double quotes. any character (backslash included) can be used by putting a backslash in front of it
    • the file can contain more @file options too, and those get processed recursively ๐ŸŒ€

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

okay bestie, go check out ar(1), objdump(1), ranlib(1), and the Info entries for binutils ๐Ÿ“š๐Ÿ’•

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 a wrap on nm, bestie ๐ŸŽ€โœจ this page is from binutils 2.45, dated 2025-12-03, and it's all about NM(1) ๐Ÿ’…๐ŸŒˆ you're literally a symbol-hunting queen now ๐Ÿ‘‘๐Ÿ’œ

๐Ÿ“ฆ where this page comes from