NM(1)
π NAME π
nm β list symbols from object files.
Okay bestie, welcome to the NM(1) page from the GNU Development Tools manual. This is the whole vibe for nm, the tool that lists symbols from object files. No cap, it's giving βbinary detectiveβ energy. πβ¨
π SYNOPSIS π
Here's the exact command shape, character for character:
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]
[-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] [-V|--version]
[-X 32_64] [--defined-only] [--no-demangle]
[--plugin name] [--size-sort] [--special-syms]
[--synthetic] [--with-symbol-versions] [--target=bfdname]
[objfile...]
πΈ DESCRIPTION πΈ
Okay so 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 uninitialized data section (known as BSS).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.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.Iβ The symbol is an indirect reference to another symbol.Nβ The symbol is a debugging symbol.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 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.
β¨ OPTIONS β¨
Okay bestie, gather round π so real talk: the long and short forms of options are literally equivalent. Same vibe, different spelling. You can use whichever one feels right in your heart.
-A,-o,--print-file-nameβ puts the name of the input file (or archive member) right before each symbol, so you can see where it came from. Like a little name tag π·οΈ. Instead of doing the boring thing of naming the input file once at the top before all its symbols.-a,--debug-symsβ shows you all the symbols, even the debugger-only ones. Those ones? Normally they stay hidden. π-Bβ literally just the same as--format=bsd. It's there for compatibility with the MIPSnm. That's it, that's the whole personality.-C,--demangle[=style]β decodes (demangles) those cursed low-level symbol names into names a human can actually read. Not only does it strip the initial underscore the system slapped on there, it also makes C++ function names readable, which is honestly a public service π. Different compilers mangle in different styles, so the optional style argument lets you pick the right demangling style for your compiler.--no-demangleβ does not demangle low-level symbol names. Fun fact: this is the default. π-D,--dynamicβ shows the dynamic symbols instead of the normal ones. Heads up: this only means anything for dynamic objects, like certain types of shared libraries.-fformat,--format=format β uses output format format, and format can be"bsd","sysv", or"posix". Default is"bsd". Also: only the *first character of *format matters, and it can be upper or lower case. Shortcut city.-g,--extern-onlyβ shows only external symbols. External babes only β¨.-h,--helpβ shows a summary of thenmoptions and dips. π«Ά-l,--line-numbersβ for each symbol it 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 symbol's address. For an undefined symbol, it looks for the line number of a relocation entry that refers to the symbol. And if it does find line number info? It prints it after all the other symbol info.--inlinesβ when-lis active and the address belongs to a function that got inlined, this option makes it print the source info for all the enclosing scopes, all the way back to the first non-inlined function. The example is kinda iconic: if"main"inlines"callee1", and"callee1"inlines"callee2", and the address is from"callee2", then the source info for"callee1"and"main"gets printed too. Nesting reveal π₯.-n,-v,--numeric-sortβ sorts the symbols numerically by their addresses instead of alphabetically by their names. Numbers over letters, always.-p,--no-sortβ doesn't even bother sorting. No order, no rules, just prints them in the order encountered. Chaos, but make it intentional. π-P,--portabilityβ uses the POSIX.2 standard output format instead of the default. Equivalent to-f posix.-r,--reverse-sortβ flips the sort order (numeric or alphabetic, whichever you picked). The last come first. Backwards slay. π-S,--print-sizeβ prints both the value and the size of defined symbols for the"bsd"output style. Warning bestie: this option does nothing for object formats that don't record symbol sizes β unless--size-sortis also used, in which case you get a calculated size instead.-s,--print-armapβ when listing symbols from archive members, this includes the index: that's the mapping (stored in the archive byarorranlib) of which modules contain definitions for which names. Receipts, basically. π§Ύ-tradix, *--radix=radix* β uses radix as the radix for printing symbol values. Rules are strict, no negotiating:dfor decimal,ofor octal, orxfor hexadecimal.-u,--undefined-onlyβ shows only undefined symbols (the ones external to each object file). The mystery symbols, if you will. π¦-V,--versionβ shows the version number ofnmand exits.-Xβ honestly? Ignored. It exists for compatibility with the AIX version ofnm. It takes one parameter, which must be the string32_64. Here's the lore: the default mode of AIXnmcorresponds to-X 32, and that one is not supported by GNUnm. So yeah. Ignored.--defined-onlyβ shows only the defined symbols for each object file.--pluginname β loads the plugin called name so you can add support for extra target types. Small catch: this option is only available if the toolchain was built with plugin support enabled.
If you don't pass --plugin 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.
Real talk β οΈ: this plugin search directory is not the same one used byld's-pluginoption. If you wantnmto 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. For Clang based compilations it's calledLLVMgold.so. Good news though: the GCC plugin is always backwards compatible with earlier versions, so copying the newest one is enough. π
--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. And if the"bsd"output format is being used, the size of the symbol is printed rather than the value β and-Smust be used if you want both size and value printed.--special-symsβ displays symbols that have a target-specific special meaning. These ones are usually used by the target for some special processing and they're not normally helpful when they show up in normal symbol lists. Example for the ARM girlies: for ARM targets this option would skip the mapping symbols used to mark transitions between ARM code, THUMB code and data.--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 because they're not part of the binary's original source code. Not canon, as it were. π--with-symbol-versionsβ enables display of symbol version info if any exists. The version string shows up as a suffix to the symbol name, preceded by an@character. Example:foo@VER_1. And if that version is the default version used when resolving unversioned references to the symbol, it's displayed as a suffix preceded by two@characters. Example:foo@@VER_2. Double at-sign, extra iconic. β¨--target=bfdname β specifies an object code format other than your system's default format.@file β reads command-line options from file. The options it reads get inserted in place of the original@file option. And 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 wrapping the entire option in either single or double quotes. Any character (including a backslash) can be included by prefixing it with a backslash. And plot twist: the file itself may contain additional @file options, and any of those get processed recursively. It's turtles all the way down π’.
πΈ SEE ALSO πΈ
ar(1), objdump(1), ranlib(1), and the Info entries for binutils. Go read your siblings' pages, they're lovely. π
π COPYRIGHT π
Copyright (c) 1991-2018 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".
Ngl that's the legal bit and you do have to read it, bestie. No skipping. π
Okay that's the whole page, you made it π This one's from binutils-2.30, dated 2018-01-27 β vintage but still serving looks. Go forth and nm something, mwah π
π¦ where this page comes from
- nixpkgs unstable: djgpp 12.2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms