NM(1)
π nm(1) β GNU Development Tools π
okay bestie, welcome to nm, the GNU Development Tools girlie who lists symbols from object files. she's iconic, she's useful, and she has so many options that we're gonna handle them in the next part. for now, let's get into the name and the whole symbol-listing vibe. π
π NAME π
nm β list symbols from object files. that's the job. she lists symbols. 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 π¦
GNU nm lists the symbols from object files objfile.... If no object files are listed as arguments, nm assumes the file a.out. periodt, that's the default-file situation. π«Ά
For each symbol, nm shows:
- the symbol value, in the radix selected by options (see below), or hexadecimal by default. yes bestie, hex is the default vibe.
- 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 (<code>u</code>, <code>v</code> and <code>w</code>). iykyk, lowercase does not always mean local β those three are the plot twist.
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. tiny data gets special treatment, no cap.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. bestie, this one is a whole lore drop.
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. code section represent π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 symbol to rule them all, literally.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. weak symbol energy, but make it system-specific.-β 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. old-school debugging tea π?β 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 examplefoo@@VER_2. double @ means default version, single @ means the other version situation β iconic little suffix moment. β¨
next up is the OPTIONS section, and bestie, it is long β part 2 is gonna be a whole journey π
β¨ OPTIONS β¨
Okay bestie, here's the thing β the long and short forms of options, shown here as alternatives, are equivalent. Pick whichever one makes your brain happy π
-A,-o,--print-file-nameβ puts the name of the input file (or the archive member) in front of each symbol, so you always know where it came from. Instead of naming the input file once at the top before all its symbols, you get it printed over and over, every single time. Repetitive? Yes. Helpful when you're grepping? Also yes π«Ά-a,--debug-symsβ shows you all the symbols, even the debugger-only ones. Normally those little guys don't get listed at all. Not me giving the debugger-only symbols their main character moment π-Bβ literally just the same as--format=bsd. It exists for compatibility with the MIPSnm. That's it. That's the whole vibe π-C,--demangle[=style]β decodes (demangles) those cursed low-level symbol names into user-level names that a human can actually read. Besides stripping off any initial underscore that the system prepended, this is what makes C++ function names readable instead of a wall of gibberish. Different compilers have different mangling styles, so the optional demangling style argument lets you pick the right one for your compiler. Slay π--no-demangleβ nope, don't demangle low-level symbol names. This is the default, bestie.--recurse-limit,--no-recurse-limit,--recursion-limit,--no-recursion-limitβ turns a limit on or off for how much recursion happens while demangling strings. Why does this matter? Because name mangling formats allow for an infinite level of recursion, so it's genuinely possible to craft strings whose decoding will gobble up all the stack space on your host machine and trigger a memory fault π The limit tries to stop that from happening by restricting recursion to 2048 levels of nesting.
The default is for this limit to be enabled, but you might need to disable it to demangle truly complicated names. Heads up though: if the recursion limit is disabled, then stack exhaustion is possible, and any bug reports about such an event will be rejected. So. Choose wisely π
-D,--dynamicβ displays the dynamic symbols instead of the normal symbols. This only actually means something for dynamic objects, like certain types of shared libraries π¦- *
-f*format,--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 is significant, and it can be either upper or lower case. So like, don't stress about spelling the whole thing out π -g,--extern-onlyβ displays only external symbols. Keeping it exclusive β¨-h,--helpβ shows a summary of the options fornmand then exits. Your little cheat sheet π«Ά- *
--ifunc-chars=CHARS* β when it displays GNU indirect function symbols,nmdefaults to using the"i"character for both local indirect functions and global indirect functions. This option lets you hand it a string with one or two characters. The first character gets used for global indirect function symbols, and the second character, if there is one, gets used for local indirect function symbols. Customise your little guys π -jβ same as--format=just-symbols. Short king π-l,--line-numbersβ for each symbol, it digs into the debugging information 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 line number info can be found, it gets printed after all the other symbol information. Detective mode activated π--inlinesβ while-lis active, if the address belongs to a function that was inlined, this option makes it print the source info for all the enclosing scopes, all the way back to the first non-inlined function. Example time, bestie: if"main"inlines"callee1"which inlines"callee2", and the address is from"callee2", then the source information for"callee1"and"main"will also be printed. It's giving family tree πΈ-n,-v,--numeric-sortβ sorts symbols numerically by their addresses instead of alphabetically by their names. Numbers > letters, no cap π’-p,--no-sortβ doesn't even bother sorting the symbols in any order; prints them in the order encountered. Chaotic. Respect π-P,--portabilityβ uses the POSIX.2 standard output format instead of the default one. Equivalent to-f posix. Fancy and standards-compliant π-r,--reverse-sortβ reverses the order of the sort (whether numeric or alphabetic); let the last come first π-S,--print-sizeβ prints both the value and the size of defined symbols for the"bsd"output style. This option has no effect for object formats that don't record symbol sizes β unless--size-sortis also used, in which case a calculated size gets displayed instead. Teamwork makes the dream work β¨-s,--print-armapβ when listing symbols from archive members, includes the index: the mapping (stored in the archive byarorranlib) of which modules contain definitions for which names. Receipts, basically π§Ύ- *
-t*radix,--radix=radix β uses radix as the radix for printing the symbol values. It must bedfor decimal,ofor octal, orxfor hexadecimal. Three choices, pick your fave π₯ -u,--undefined-onlyβ displays only undefined symbols (the ones external to each object file). By default both defined and undefined symbols are displayed, so this narrows it right down π―-U,--defined-onlyβ displays only defined symbols for each object file. Again, by default both defined and undefined symbols are displayed. The opposite of the previous one, iykyk π-V,--versionβ shows the version number ofnmand exits. Say hi to the version β¨-Xβ this option is ignored, purely 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 it just sits there, vibing, doing nothing π- *
--plugin*name β loads the plugin called name to add support for extra target types. This option is only available if the toolchain has been 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 is 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, it has to 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. Copy-paste queen π
--size-sortβ sorts symbols by size. For ELF objects the 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-Smust 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. Can't measure what isn't there π
--special-symsβ displays symbols which have a target-specific special meaning. These symbols are usually used by the target for some special processing and are not normally helpful when included 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. Let them out of the vault π--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 aren't part of the binary's original source code. Linker-made, not hand-written π--unicode=[default|invalid|locale|escape|hex|highlight]β controls how UTF-8 encoded multibyte characters get displayed in strings. Let's break it down, bestie:- The default (
--unicode=default) gives them no special treatment at all. --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 intended to draw attention to unicode sequences where they might not be expected π
- The default (
-W,--no-weakβ doesn't display weak symbols. Weak symbols found crying in the club π--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 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. Double at-signs for the VIPs π- *
--target=bfdname* β specifies an object code format other than your system's default format. Branching out π - *
@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 not removed π«Ά
Options inside 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 the whole friend group β¨
π COPYRIGHT π
Copyright (c) 1991-2026 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". Legal but make it cute π
And that's the whole page, bestie β this masterpiece is from binutils-2.47, dated 2026-08-31. Go forth and demangle π¦β
π¦ where this page comes from
- arch rolling: riscv64-linux-gnu-binutils 2.47-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms