NM(1)
๐ 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 lowercasecshows 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 globalintversus 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, likefoo@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, likefoo@@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 symbolsjโ 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-lis 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 byarorranlib) showing which modules define which names-t radix,--radix=radixโ choose the radix for printing symbol values. it has to bedfor decimal,ofor octal, orxfor 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 string32_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
--pluginbut plugin support is enabled, nm checks the files in${libdir}/bfd-pluginsin 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
-pluginoption uses ๐ โโ๏ธ for nm to use the linker plugin, you have to copy it into the${libdir}/bfd-pluginsdirectory. for GCC-based compilations, the linker plugin is calledliblto_plugin.so.0.0.0, and for Clang-based compilations it's calledLLVMgold.so. the GCC plugin is always backwards compatible with earlier versions, so copying just the newest one is enough ๐
- if you don't give
--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-Sif you want both size and value- > ๐ note: this doesn't work if
--undefined-onlyis enabled, because undefined symbols have no size
- > ๐ note: this doesn't work if
--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=defaultis the default, and gives them no special treatment--unicode=localedisplays the sequence in the current locale, which may or may not support them--unicode=hexand--unicode=invaliddisplay them as hex byte sequences wrapped in either angle brackets or curly braces--unicode=escapedisplays them as escape sequences like\uxxxx--unicode=highlightdisplays 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, likefoo@VER_1. if it's the default version used when resolving unversioned references to the symbol, it's shown with two@characters instead, likefoo@@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@fileoption 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
@fileoptions 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 ๐
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
- ubuntu questing: binutils-common 2.45-7ubuntu1.2
- ubuntu questing: binutils-x86-64-linux-gnu 2.45-7ubuntu1.2
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms