gcc-nm-4.8
List symbols from object files (gcc-4.8)
SYNOPSIS
gcc-nm-4.8 [options] object-file...
PARAMETERS
-a, --debug-syms
Display all symbols, even debugger-only symbols.
-A, -o, --print-file-name
Precede each symbol with the object file it came from.
-B
Equivalent to --format=bsd.
-C, --demangle
Demangle low-level symbol names into user-level names; makes C++ function names more readable.
-D, --dynamic
Display dynamic symbols only.
-f, --format=
Use the specified output format. Valid formats are `bsd`, `sysv`, and `posix`.
-g, --extern-only
Display only external symbols.
-n, -v, --numeric-sort
Sort symbols numerically by their address.
-p, --no-sort
Do not sort the symbols.
-P, --portability
Equivalent to --format=posix.
-r, --reverse-sort
Reverse the sort order.
-s, --print-armap
Print the archive index (armap).
-t
Print the symbol value using the specified radix ('d' for decimal, 'o' for octal, 'x' for hexadecimal).
-u, --undefined-only
Display only undefined symbols.
-w, --wide
Do not truncate output lines.
--help
Display help information.
--version
Display version information.
DESCRIPTION
The `gcc-nm-4.8` command (typically referred to as `nm`) displays the symbol table of object files, executable files, and object-file archives. The symbol table contains information about the symbols defined and used within the file, such as function names, variable names, section names, and source file names. This information is crucial for debugging, reverse engineering, and understanding the structure of compiled programs. `gcc-nm-4.8` refers to the `nm` version that is compatible with GCC version 4.8. The command outputs a list of symbols, their addresses (if available), their types (e.g., text, data, bss), and their names. Different options allow you to control the output format, sort order, and filtering of symbols. It's an essential tool for developers working with compiled languages like C and C++ to inspect the internal workings of their programs and libraries. Symbols may be undefined, defined, or even removed during linking.
CAVEATS
The output format and symbol types displayed can vary depending on the object file format and the specific options used. Demangling is compiler-dependent and might not always produce perfectly readable names. It's possible for different compilers (even different versions of GCC) to produce object files with slightly different symbol table formats, which could affect `nm`'s output.
SYMBOL TYPES
The output usually includes a letter indicating the symbol type:
A: Absolute.
B: BSS section (uninitialized data).
C: Common symbol.
D: Initialized data section.
G: Initialized data section for small objects.
I: rodata section, usually for literals.
N: Debugging symbol.
R: Read-only data section.
S: Uninitialized small object section.
T: Text section (code).
U: Undefined symbol.
V: Weak object.
W: Weak symbol.
-: stabs symbol in an a.out object file.
USAGE EXAMPLE
gcc-nm-4.8 -C myprogram.o
This command displays the symbols in the `myprogram.o` object file, with C++ names demangled for better readability. gcc-nm-4.8 -D mylibrary.so
lists dynamic symbols of a shared library.
HISTORY
The `nm` command has been a standard utility in Unix-like systems for a long time. Its primary purpose is to provide insight into the symbol tables of compiled objects. As compilers evolved, like gcc, so too did supporting utilities such as `nm`. Thus, `gcc-nm-4.8` is a version of `nm` specifically designed to work well with the object files generated by GCC version 4.8. This helps ensure compatibility and accurate symbol interpretation.