llvm-project/llvm/docs/CommandGuide/llvm-nm.rst

213 lines
4.7 KiB
ReStructuredText

llvm-nm - list LLVM bitcode and object file's symbol table
==========================================================
SYNOPSIS
--------
:program:`llvm-nm` [*options*] [*filenames...*]
DESCRIPTION
-----------
The :program:`llvm-nm` utility lists the names of symbols from the LLVM bitcode
files, object files, or :program:`ar` archives containing them, named on the
command line. Each symbol is listed along with some simple information about
its provenance. If no filename is specified, *a.out* is used as the input.
If *-* is used as a filename, :program:`llvm-nm` will read a file from its
standard input stream.
:program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
output format. Each such output record consists of an (optional) 8-digit
hexadecimal address, followed by a type code character, followed by a name, for
each symbol. One record is printed per line; fields are separated by spaces.
When the address is omitted, it is replaced by 8 spaces.
Type code characters currently supported, and their meanings, are as follows.
Where both lower and upper-case characters are listed for the same meaning, a
lower-case character represents a local symbol, whilst an upper-case character
represents a global (external) symbol:
a, A
Absolute symbol.
b, B
Unitialized data (bss) object.
C
Common symbol. Multiple definitions link together into one definition.
d, D
Writable data object.
i, I
COFF: .idata symbol or symbol in a section with IMAGE_SCN_LNK_INFO set.
n
ELF: local symbol from non-alloc section.
COFF: debug symbol.
N
ELF: debug section symbol, or global symbol from non-alloc section.
s, S
COFF: section symbol.
Mach-O: absolute symbol or symbol from a section other than __TEXT_EXEC __text,
__TEXT __text, __DATA __data, or __DATA __bss.
r, R
Read-only data object.
t, T
Code (text) object.
u
ELF: GNU unique symbol.
U
Named object is undefined in this file.
v
ELF: Undefined weak object. It is not a link failure if the object is not
defined.
V
ELF: Defined weak object symbol. This definition will only be used if no
regular definitions exist in a link. If multiple weak definitions and no
regular definitons exist, one of the weak definitions will be used.
w
Undefined weak symbol other than an ELF object symbol. It is not a link failure
if the symbol is not defined.
W
Defined weak symbol other than an ELF object symbol. This definition will only
be used if no regular definitions exist in a link. If multiple weak definitions
and no regular definitons exist, one of the weak definitions will be used.
\-
Mach-O: N_STAB symbol.
?
Something unrecognizable.
Because LLVM bitcode files typically contain objects that are not considered to
have addresses until they are linked into an executable image or dynamically
compiled "just-in-time", :program:`llvm-nm` does not print an address for any
symbol in an LLVM bitcode file, even symbols which are defined in the bitcode
file.
OPTIONS
-------
.. program:: llvm-nm
.. option:: -B (default)
Use BSD output format. Alias for `--format=bsd`.
.. option:: -P
Use POSIX.2 output format. Alias for `--format=posix`.
.. option:: --debug-syms, -a
Show all symbols, even debugger only.
.. option:: --defined-only
Print only symbols defined in this file (as opposed to
symbols which may be referenced by objects in this file, but not
defined in this file.)
.. option:: --dynamic, -D
Display dynamic symbols instead of normal symbols.
.. option:: --extern-only, -g
Print only symbols whose definitions are external; that is, accessible
from other files.
.. option:: --no-weak, -W
Don't print any weak symbols in the output.
.. option:: --format=format, -f format
Select an output format; *format* may be *sysv*, *posix*, *darwin*, or *bsd*.
The default is *bsd*.
.. option:: --help, -h
Print a summary of command-line options and their meanings.
.. option:: --no-sort, -p
Shows symbols in order encountered.
.. option:: --numeric-sort, -n, -v
Sort symbols by address.
.. option:: --print-file-name, -A, -o
Precede each symbol with the file it came from.
.. option:: --print-size, -S
Show symbol size as well as address (not applicable for Mach-O).
.. option:: --size-sort
Sort symbols by size.
.. option:: --undefined-only, -u
Print only symbols referenced but not defined in this file.
.. option:: --radix=RADIX, -t
Specify the radix of the symbol address(es). Values accepted d(decimal),
x(hexadecimal) and o(octal).
.. option:: @<FILE>
Read command-line options from response file `<FILE>`.
BUGS
----
* :program:`llvm-nm` does not support the full set of arguments that GNU
:program:`nm` does.
EXIT STATUS
-----------
:program:`llvm-nm` exits with an exit code of zero.
SEE ALSO
--------
llvm-dis, ar(1), nm(1)