llvm-nm
List symbols from object files
TLDR
View documentation for the original command
SYNOPSIS
llvm-nm [options] files...
PARAMETERS
-a, --debug-syms
Display all symbols, including debugger-only symbols.
-D, --dynamic
Display only dynamic symbols.
-g, --extern-only
Display only external symbols.
-n, --numeric-sort
Sort symbols by their address numerically.
-P, --portability
Use POSIX.2 format for the output. This ensures a consistent, parsable format.
-r, --reverse-sort
Reverse the order of the sort for the symbols.
-S, --print-size
Print the size of data symbols in addition to other information.
-t
Display symbol values in the specified radix (d for decimal, o for octal, x for hexadecimal).
-u, --undefined-only
Display only undefined symbols. These are symbols referenced but not defined in the object file.
--defined-only
Display only defined symbols. These are symbols that have a definition within the object file.
--print-file-name
Precede each symbol's information with the name of the file it came from, useful when processing multiple files.
--help
Display a brief usage message and exit.
--version
Display the version of llvm-nm and exit.
DESCRIPTION
llvm-nm is a utility included in the LLVM toolchain designed to list symbols from object files, archives, and shared libraries. It provides information about the symbols defined or referenced within a given binary file, including their name, type, value, and section. This tool is particularly useful for inspecting compiled code, debugging, and understanding the structure of executable binaries or libraries.
It supports various object file formats commonly used in systems where LLVM is deployed and can also operate on LLVM bitcode files, offering insight into the symbol tables generated by LLVM compilers. It's an essential tool for developers working with C, C++, and other languages compiled by LLVM, offering a modern alternative to the traditional nm command within the LLVM ecosystem.
CAVEATS
llvm-nm is designed to integrate seamlessly with the LLVM ecosystem. While it aims for compatibility with GNU nm, there might be subtle differences in output formatting or behavior for certain esoteric flags or specific object file types. It is primarily optimized for object files and bitcode generated by LLVM compilers.
SYMBOL TYPE CHARACTERS
The second column of llvm-nm's output typically shows the type of the symbol. The character can be lowercase or uppercase, with uppercase generally indicating a global or external symbol and lowercase indicating a local symbol.
Some common types include:
A: Absolute symbol
B: Uninitialized data segment (BSS)
C: Common symbol
D: Initialized data segment
I: Indirect symbol (e.g., PLT entry)
N: Debug symbol
R: Read-only data segment
T: Text (code) segment
U: Undefined symbol (referenced but not defined in this file)
W: Weak symbol
V: Weak object
-: Stabs debug symbol
?: Unknown or unsupported symbol type
HISTORY
llvm-nm is an integral part of the LLVM project, which originated in 2000 at the University of Illinois Urbana-Champaign. It was developed to provide a modern, modular, and reusable set of compiler technologies. llvm-nm was created as part of this broader initiative to offer symbol table inspection capabilities consistent with the LLVM internal object file model. It serves as a direct replacement for the GNU nm utility within an LLVM-centric development workflow, evolving alongside the general advancement and adoption of the LLVM toolchain.
SEE ALSO
nm(1), llvm-objdump(1), llvm-readelf(1), ar(1)