NM(1)

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

🌸 nm(1) β€” GNU Development Tools 🌸

okay bestie, welcome to the manual page for nm(1) from GNU Development Tools. it's giving symbol-listing excellence, no cap. πŸ’…


πŸ’– 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 list any object files as arguments, nm assumes the file a.out. periodt. πŸ’–

For each symbol, nm shows:

  • 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, v and w).
    • A β€” The symbol's value is absolute, and will not be changed by further linking.
    • 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.
    • 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.
  • 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. 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. 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.

✨ OPTIONS ✨

Okay bestie, here's the thing β€” the long form and the short form of every option do exactly the same thing. They're literally just alternatives, pick whichever one your fingers feel like typing. πŸ’…


  • -A, -o, --print-file-name β€” put the name of the input file (or the archive member) in front of every single symbol it was found in, instead of naming the input file once at the top and then dumping all its symbols after. iykyk ✨
  • -a, --debug-syms β€” show all the symbols, even the debugger-only ones. Normally those ones don't get listed at all. πŸ™ˆ
  • -B β€” same thing as --format=bsd, kept around so it plays nice with the MIPS nm. πŸ’–
  • -C, --demangle[=style] β€” decode (demangle) those crusty low-level symbol names back into human-level names. Besides stripping off any leading underscore that the system slapped on, this is what makes C++ function names actually readable. Different compilers mangle in different styles, so the optional demangling style argument lets you pick the right style for your compiler. πŸ‘‘
  • --no-demangle β€” don't demangle low-level symbol names. This is the default, no cap.
  • --recurse-limit, --no-recurse-limit, --recursion-limit, --no-recursion-limit β€” turns the recursion limit for demangling on or off. The name mangling formats allow for infinite recursion, so it's totally possible to craft strings whose decoding eats up all the stack space on your host machine and triggers a memory fault. 😭 The limit tries to stop that by capping recursion at 2048 levels of nesting.

The default is that this limit is enabled, but you might need to disable it to demangle truly complicated names. But like, heads up β€” if you disable the recursion limit then stack exhaustion is possible, and any bug reports about that happening will be rejected. πŸ’€

  • -D, --dynamic β€” show the dynamic symbols instead of the normal ones. This only means anything 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 actually matters, and it can be upper or lower case. πŸŽ€
  • -g, --extern-only β€” only show external symbols.
  • -h, --help β€” show a lil summary of the options for nm and exit. πŸ¦‹
  • --ifunc-chars=CHARS β€” when showing GNU indirect function symbols, nm defaults to using the "i" character for both local and global indirect functions. This option lets you hand it a string with one or two characters: the first character is used for global indirect function symbols and the second one, if you even gave a second one, is used for local indirect function symbols.
  • j β€” same as --format=just-symbols.
  • -l, --line-numbers β€” for every symbol, dig into the debugging information and try to find a filename and line number. For a defined symbol, look for the line number of the address of the symbol. For an undefined symbol, look for the line number of a relocation entry that refers to the symbol. If line number info can be found, it gets printed after all 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 back to the first non-inlined function print out too. Like, if "main" inlines "callee1" which inlines "callee2", and the address is from "callee2", then the source info for "callee1" and "main" gets printed as well. 🀯
  • -n, -v, --numeric-sort β€” sort symbols numerically by their addresses, instead of alphabetically by their names.
  • -p, --no-sort β€” don't even bother sorting the symbols into any order, just print them in the order you encountered them. chaotic but valid πŸ™ˆ
  • -P, --portability β€” use the POSIX.2 standard output format instead of the default. Equivalent to -f posix.
  • -r, --reverse-sort β€” flip the order of the sort, whether numeric or alphabetic. Last comes first, main character energy. πŸ‘‘
  • -S, --print-size β€” print both the value and the size of defined symbols for the "bsd" output style. This option does nothing 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, include the index: a mapping (stored in the archive by ar or ranlib) of which modules contain definitions for which names. πŸ’–
  • -t radix, --radix=radix β€” use radix as the radix for printing the 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 external to each object file). By default both defined and undefined symbols are displayed.
  • -U, --defined-only β€” only show defined symbols for each object file. By default both defined and undefined symbols are displayed.
  • -V, --version β€” show the version number of nm and exit. ✨
  • -X β€” this one is ignored, kept 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 corresponds to -X 32, which GNU nm does not support.
  • --plugin name β€” load 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. To make nm 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. For Clang based compilations it's called LLVMgold.so. The GCC plugin is always backwards compatible with earlier versions, so it's enough to just copy the newest one. 🫢

  • --size-sort β€” sort symbols by size. For ELF objects the symbol sizes are read from the ELF; for other object types the 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 gets printed rather than the value, and -S must be used for both size and value to be printed.
Heads up β€” this option does not work if --undefined-only has been enabled, because undefined symbols have no size. πŸ’€
  • --special-syms β€” show 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 β€” include synthetic symbols in the output. These are special symbols created by the linker for various purposes, and they're not shown by default since they're not part of the binary's original source code. 🧚
  • --unicode=[default|invalid|locale|escape|hex|highlight] β€” controls how UTF-8 encoded multibyte characters get displayed in strings. The default (--unicode=default) is to give 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 options --unicode=hex and --unicode=invalid 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 the output device supports that). The colouring is meant to draw attention to unicode sequences where you might not be expecting them. 🌈

  • -W, --no-weak β€” don't display weak symbols.
  • --with-symbol-versions, --without-symbol-versions β€” enables or disables showing 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 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 β€” specify an object code format other than your system's default format.
  • @file β€” read 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 not removed.

Options in file are separated by whitespace. A whitespace character can be included in an option by wrapping the entire option in either single or double quotes. Any character (including a backslash) can be included by putting a backslash in front of the character you want in. The file may itself contain additional @file options, and any of those will be processed recursively. πŸŒ€


🌟 SEE ALSO 🌟

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".


okay that's the whole page bestie, you ate that πŸŽ€ this one's from binutils-2.45.50, dated 2025-12-09 β€” go forth and demangle, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from