LinuxCommandLibrary

nm-classic

Display symbol table information from object files

TLDR

View documentation for the original command

$ tldr nm
copy

SYNOPSIS

nm-classic [options] [object_file...]

PARAMETERS

-a, --debug-syms
    Display all symbols, including debugger-only symbols.

-C, --demangle
    Demangle low-level symbol names into user-level names.

-D, --dynamic
    Display dynamic symbols only.

-g, --extern-only
    Display only external (global) symbols.

-n, --numeric-sort
    Sort symbols numerically by address.

-P, --portability
    Use the POSIX.2 output format, similar to SVR4 nm.

-r, --reverse-sort
    Reverse the order of the sort (ascending to descending or vice-versa).

-S, --print-size
    Print symbol size in addition to other information.

-u, --undefined-only
    Display only undefined symbols (symbols referenced but not defined in the object file).

-V, --version
    Print the version number of nm.

--help
    Print a summary of the options and exit.

--no-sort
    Do not sort the symbols; display them in the order encountered in the object file.

DESCRIPTION

nm-classic is a utility program that lists symbols from object files, executable files, and object-file archives (libraries). It is part of the GNU Binutils package and is used to inspect the symbol table of compiled binaries.

Symbols represent functions, global variables, and other named entities defined or referenced within the code. Understanding the symbol table is crucial for debugging, linking, and analyzing compiled programs, allowing developers to see what functions are exported, imported, or internally used by a module. The "classic" suffix often distinguishes it from alternative nm implementations, such as llvm-nm, ensuring the use of the traditional GNU version.

CAVEATS

nm-classic is a specific alias or symlink to the GNU Binutils nm command. Users should be aware that other nm implementations (e.g., from LLVM/Clang) might exist on their system and have slightly different features or output formats. Using nm-classic guarantees the behavior of the traditional GNU toolchain's symbol lister, which relies on the BFD (Binary File Descriptor) library for object file parsing.

SYMBOL TYPES

Symbols listed by nm are typically followed by a character indicating their type (e.g., 'T' for text section, 'D' for data section, 'B' for BSS section, 'U' for undefined, 'W' for weak, 'A' for absolute). Lowercase indicates a local symbol, while uppercase indicates a global (external) symbol.

OUTPUT FORMAT

The default output format for nm typically includes the symbol's address (if defined), the symbol type character, and the symbol name. Options like -P or --portability can change this format for easier parsing by scripts or other tools, ensuring a consistent output across different systems.

HISTORY

The nm utility is a standard tool in Unix-like operating systems, tracing its roots back to early AT&T Unix versions. nm-classic specifically refers to the version provided by the GNU Binutils project, a collection of programming tools for creating and managing binary programs. GNU Binutils, including nm, has been under active development since the 1980s and is a cornerstone of the GNU toolchain, widely used in Linux and other Unix-like systems. The nm-classic alias or executable typically arises in environments where alternative nm implementations (like llvm-nm from the LLVM project) might be present, allowing users to explicitly choose the GNU Binutils version.

SEE ALSO

objdump(1), readelf(1), ar(1), strip(1)

Copied to clipboard