NM(1)
π¦ nm(1) from GNU Development Tools π¦
Okay bestie, welcome to the nm(1) page from GNU Development Tools β this is literally the symbol-listing tea, and we're about to sip it together. No cap, it's giving βmicroscope for object files,β and the vibes are immaculate. π
β¨ 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 π
GNU nm lists the symbols from object files objfile.... If no object files are listed as arguments, nm assumes 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. 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.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 caseccharacter 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 ana.outobject 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 examplefoo@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 examplefoo@@VER_2. π¦
β¨ OPTIONS β¨
Okay so bestie, the long and short forms of options are literally interchangeable β -A and --print-file-name do the exact same thing. Pick whichever one slaps for you π
-A,-o,--print-file-nameβ puts the name of the input file (or the archive member, iykyk) right before each symbol where it was found, instead of the boring way where the file gets named once at the top before all its symbols. Much more readable, ngl.-a,--debug-symsβ shows all the symbols, even the debugger-only ones that normally get left out of the party π-Bβ literally just the same as--format=bsd, and it exists purely for compatibility with the MIPSnm. That's it, that's the whole vibe.-C,--demangle[=style]β decodes (demangles) those low-level symbol names into actual human-level names π§ besides ripping off the initial underscore that the system prepended, this is what makes C++ function names readable instead of looking like a cursed keyboard smash. Different compilers mangle in different styles, so you can hit it with the optional demangling style argument to pick the right one for your compiler. Slay.--no-demangleβ nope, don't demangle anything. This is the default, so it's giving "leave it low level."--recurse-limit,--no-recurse-limit,--recursion-limit,--no-recursion-limitβ turns the limit on or off for how much recursion happens while demangling strings. So here's the tea: name mangling formats allow for infinite recursion, which means someone can absolutely craft strings whose decoding eats up all the stack space on your host machine and triggers a memory fault π the limit exists 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, absurdly complicated names. Big warning though: if you turn the recursion limit off, stack exhaustion is genuinely possible, and any bug reports about that happening will be rejected. So like... you were warned, bestie π«Ά
-D,--dynamicβ shows the dynamic symbols instead of the normal ones. This only actually means anything for dynamic objects, like certain types of shared libraries.-fformat,--format=format β uses the output format format, which can be"bsd","sysv","posix"or"just-symbols". The default is"bsd". Only the first character of format matters, and it can be upper or lower case. So-f p= posix, iconic.-g,--extern-onlyβ only the external symbols, nothing else. Filtered, periodt.-h,--helpβ shows you a lil summary of the options fornmand then dips out.--ifunc-chars=CHARSβ so whennmdisplays GNU indirect function symbols, it defaults to using the"i"character for both local indirect functions 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 character (if you even give one) is used for local indirect function symbols. Customize away πjβ same as--format=just-symbols. That's it, one little letter.-l,--line-numbersβ for each symbol, uses the debugging info to try to 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 it finds line number info, it prints it after the rest of the symbol information. Chef's kiss.--inlinesβ when-lis active and 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 time: 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. Full context, no crumbs.-n,-v,--numeric-sortβ sorts symbols numerically by their addresses instead of alphabetically by their names. Numbers go brrr π-p,--no-sortβ doesn't bother sorting at all; just prints them in the order encountered. Chaotic, but valid.-P,--portabilityβ uses the POSIX.2 standard output format instead of the default. Equivalent to-f posix.-r,--reverse-sortβ flips the order of the sort (numeric or alphabetic, whichever you picked); last comes first, main character energy π-S,--print-sizeβ prints both the value and the size of defined symbols for the"bsd"output style. Heads up: this option does nothing for object formats that don't record symbol sizes β unless--size-sortis also used, in which case a calculated size gets displayed. Sneaky but useful.-s,--print-armapβ when listing symbols from archive members, includes the index: that's a mapping (stored in the archive byarorranlib) of which modules contain definitions for which names. Very "who's who" of your archive π-tradix,--radix=radix β uses radix as the base for printing symbol values. It has to bedfor decimal,ofor octal, orxfor hexadecimal. No other letters, don't try it.-u,--undefined-onlyβ only undefined symbols (the ones external to each object file). By default, both defined and undefined symbols are displayed.-U,--defined-onlyβ only defined symbols for each object file. Again, by default both kinds show up.-V,--versionβ shows the version number ofnmand exits. Bye π-Xβ this one is just ignored, 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 GNUnmdoes not support. So like, don't come at it expecting AIX behavior.--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 (important!): this plugin search directory is not the one used by ld's -plugin option. To get 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 it's enough to just copy the newest one, and you're set π
--size-sortβ sorts symbols by size. For ELF objects, symbol sizes are read right 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-Smust be used 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. Math, bestie. π
--special-symsβ displays symbols that have a target-specific special meaning. These are usually used by the target for some special processing and are normally not helpful when included in normal symbol lists. Example: for ARM targets, this option would skip the mapping symbols used to mark transitions between ARM code, THUMB code and data. Niche but iconic.--syntheticβ includes 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. Linker-made, not source-made π¦--unicode=[default|invalid|locale|escape|hex|highlight]β controls how UTF-8 encoded multibyte characters get displayed in strings.--unicode=defaultgives them no special treatment at all (this is the default, obviously).--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=escapedisplays them as escape sequences (\uxxxx).--unicode=highlightdisplays them as escape sequences highlighted in red (if supported by the output device). The colouring is literally meant to draw attention to unicode sequences where you might not expect them π
-W,--no-weakβ does not display weak symbols. Weak ones, be gone.--with-symbol-versions,--without-symbol-versionsβ enables or disables displaying symbol version information. The version string shows up as a suffix to the symbol name, preceded by an@character β likefoo@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 β likefoo@@VER_2. By default, symbol version info is displayed. Double@is the default-version tell, iykyk β--target=bfdname β specifies an object code format other than your system's default format. Go pick a different one, bestie.@file β reads command-line options from file. The options 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. No disappearing acts π
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. And the file may itself contain additional @file options β any such options get processed recursively. It's files all the way down π
π SEE ALSO π
ar(1), objdump(1), ranlib(1), and the Info entries for binutils. Go read those too, they're the supporting cast π
π COPYRIGHT π
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! This masterpiece is from binutils-2.45.1, dated 2026-01-23, and it's the one and only NM(1) π«Άβ¨
π¦ where this page comes from
- arch rolling: sh2-elf-binutils 2.45.1-1 Β· GPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms