blob: dabc83cce6c6aa62c00653872488fcb1b569f031 [file] [log] [blame]
Michael J. Spencer838e5ad2012-06-06 23:34:10 +00001llvm-nm - list LLVM bitcode and object file's symbol table
2==========================================================
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00003
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00004SYNOPSIS
5--------
6
Michael J. Spencer838e5ad2012-06-06 23:34:10 +00007:program:`llvm-nm` [*options*] [*filenames...*]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00008
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00009DESCRIPTION
10-----------
11
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000012The :program:`llvm-nm` utility lists the names of symbols from the LLVM bitcode
13files, object files, or :program:`ar` archives containing them, named on the
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000014command line. Each symbol is listed along with some simple information about
James Hendersonbe7f5c72019-06-11 13:46:52 +000015its provenance. If no filename is specified, *a.out* is used as the input.
16If *-* is used as a filename, :program:`llvm-nm` will read a file from its
17standard input stream.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000018
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000019:program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000020output format. Each such output record consists of an (optional) 8-digit
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000021hexadecimal address, followed by a type code character, followed by a name, for
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000022each symbol. One record is printed per line; fields are separated by spaces.
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000023When the address is omitted, it is replaced by 8 spaces.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000024
James Henderson3519d552019-06-24 09:53:02 +000025Type code characters currently supported, and their meanings, are as follows.
26Where both lower and upper-case characters are listed for the same meaning, a
27lower-case character represents a local symbol, whilst an upper-case character
28represents a global (external) symbol:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000029
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000030
James Henderson3519d552019-06-24 09:53:02 +000031a, A
32
33 Absolute symbol.
34
35b, B
36
37 Unitialized data (bss) object.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000038
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000039C
40
James Henderson3519d552019-06-24 09:53:02 +000041 Common symbol. Multiple definitions link together into one definition.
42
43d, D
44
45 Writable data object.
46
47i, I
48
49 COFF: .idata symbol or symbol in a section with IMAGE_SCN_LNK_INFO set.
50
51n
52
53 ELF: local symbol from non-alloc section.
54
55 COFF: debug symbol.
56
57N
58
59 ELF: debug section symbol, or global symbol from non-alloc section.
60
61s, S
62
63 COFF: section symbol.
64
65 Mach-O: absolute symbol or symbol from a section other than __TEXT_EXEC __text,
66 __TEXT __text, __DATA __data, or __DATA __bss.
67
68r, R
69
70 Read-only data object.
71
72t, T
73
74 Code (text) object.
75
76u
77
78 ELF: GNU unique symbol.
79
80U
81
82 Named object is undefined in this file.
83
84v
85
86 ELF: Undefined weak object. It is not a link failure if the object is not
87 defined.
88
89V
90
91 ELF: Defined weak object symbol. This definition will only be used if no
92 regular definitions exist in a link. If multiple weak definitions and no
93 regular definitons exist, one of the weak definitions will be used.
94
95w
96
97 Undefined weak symbol other than an ELF object symbol. It is not a link failure
98 if the symbol is not defined.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000099
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000100W
101
James Henderson3519d552019-06-24 09:53:02 +0000102 Defined weak symbol other than an ELF object symbol. This definition will only
103 be used if no regular definitions exist in a link. If multiple weak definitions
104 and no regular definitons exist, one of the weak definitions will be used.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000105
James Henderson3519d552019-06-24 09:53:02 +0000106\-
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000107
James Henderson3519d552019-06-24 09:53:02 +0000108 Mach-O: N_STAB symbol.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000109
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000110?
111
James Henderson3519d552019-06-24 09:53:02 +0000112 Something unrecognizable.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000113
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000114Because LLVM bitcode files typically contain objects that are not considered to
115have addresses until they are linked into an executable image or dynamically
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000116compiled "just-in-time", :program:`llvm-nm` does not print an address for any
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000117symbol in an LLVM bitcode file, even symbols which are defined in the bitcode
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000118file.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000119
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000120OPTIONS
121-------
122
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000123.. program:: llvm-nm
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000124
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000125.. option:: -B (default)
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000126
Renato Golin124f2592016-07-20 12:16:38 +0000127 Use BSD output format. Alias for `--format=bsd`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000128
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000129.. option:: -P
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000130
Renato Golin124f2592016-07-20 12:16:38 +0000131 Use POSIX.2 output format. Alias for `--format=posix`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000132
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000133.. option:: --debug-syms, -a
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000134
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000135 Show all symbols, even debugger only.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000136
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000137.. option:: --defined-only
138
139 Print only symbols defined in this file (as opposed to
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000140 symbols which may be referenced by objects in this file, but not
141 defined in this file.)
142
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000143.. option:: --dynamic, -D
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000144
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000145 Display dynamic symbols instead of normal symbols.
146
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000147.. option:: --extern-only, -g
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000148
149 Print only symbols whose definitions are external; that is, accessible
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000150 from other files.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000151
Dave Leed4f77a52018-07-02 17:24:37 +0000152.. option:: --no-weak, -W
153
154 Don't print any weak symbols in the output.
155
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000156.. option:: --format=format, -f format
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000157
James Henderson5058ae02019-06-11 15:58:10 +0000158 Select an output format; *format* may be *sysv*, *posix*, *darwin*, or *bsd*.
159 The default is *bsd*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000160
James Henderson224410b2019-06-11 14:55:31 +0000161.. option:: --help, -h
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000162
163 Print a summary of command-line options and their meanings.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000164
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000165.. option:: --no-sort, -p
166
167 Shows symbols in order encountered.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000168
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000169.. option:: --numeric-sort, -n, -v
170
171 Sort symbols by address.
172
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000173.. option:: --print-file-name, -A, -o
174
175 Precede each symbol with the file it came from.
176
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000177.. option:: --print-size, -S
178
James Henderson2c16bb82019-06-12 10:44:41 +0000179 Show symbol size as well as address (not applicable for Mach-O).
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000180
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000181.. option:: --size-sort
182
183 Sort symbols by size.
184
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000185.. option:: --undefined-only, -u
186
187 Print only symbols referenced but not defined in this file.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000188
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000189.. option:: --radix=RADIX, -t
190
191 Specify the radix of the symbol address(es). Values accepted d(decimal),
James Henderson4cfcacb2019-06-12 10:48:33 +0000192 x(hexadecimal) and o(octal).
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000193
James Henderson9485b262019-06-21 11:49:20 +0000194.. option:: @<FILE>
195
196 Read command-line options from response file `<FILE>`.
197
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000198BUGS
199----
200
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000201 * :program:`llvm-nm` does not support the full set of arguments that GNU
202 :program:`nm` does.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000203
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000204EXIT STATUS
205-----------
206
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000207:program:`llvm-nm` exits with an exit code of zero.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000208
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000209SEE ALSO
210--------
211
Dmitri Gribenko8cac8352013-08-18 08:32:32 +0000212llvm-dis, ar(1), nm(1)