blob: a153ea3e1c5df8ea98541ed555d819812fe4fe8c [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
James Hendersona0566842019-06-27 13:24:46 +00004.. program:: llvm-nm
5
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00006SYNOPSIS
7--------
8
Michael J. Spencer838e5ad2012-06-06 23:34:10 +00009:program:`llvm-nm` [*options*] [*filenames...*]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000010
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000011DESCRIPTION
12-----------
13
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000014The :program:`llvm-nm` utility lists the names of symbols from the LLVM bitcode
15files, object files, or :program:`ar` archives containing them, named on the
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000016command line. Each symbol is listed along with some simple information about
James Hendersonbe7f5c72019-06-11 13:46:52 +000017its provenance. If no filename is specified, *a.out* is used as the input.
18If *-* is used as a filename, :program:`llvm-nm` will read a file from its
19standard input stream.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000020
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000021:program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000022output format. Each such output record consists of an (optional) 8-digit
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000023hexadecimal address, followed by a type code character, followed by a name, for
Dmitri Gribenko8cac8352013-08-18 08:32:32 +000024each symbol. One record is printed per line; fields are separated by spaces.
Michael J. Spencer838e5ad2012-06-06 23:34:10 +000025When the address is omitted, it is replaced by 8 spaces.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000026
James Henderson3519d552019-06-24 09:53:02 +000027Type code characters currently supported, and their meanings, are as follows.
28Where both lower and upper-case characters are listed for the same meaning, a
29lower-case character represents a local symbol, whilst an upper-case character
30represents a global (external) symbol:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000031
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000032
James Henderson3519d552019-06-24 09:53:02 +000033a, A
34
35 Absolute symbol.
36
37b, B
38
39 Unitialized data (bss) object.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000040
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000041C
42
James Henderson3519d552019-06-24 09:53:02 +000043 Common symbol. Multiple definitions link together into one definition.
44
45d, D
46
47 Writable data object.
48
49i, I
50
51 COFF: .idata symbol or symbol in a section with IMAGE_SCN_LNK_INFO set.
52
53n
54
55 ELF: local symbol from non-alloc section.
56
57 COFF: debug symbol.
58
59N
60
61 ELF: debug section symbol, or global symbol from non-alloc section.
62
63s, S
64
65 COFF: section symbol.
66
67 Mach-O: absolute symbol or symbol from a section other than __TEXT_EXEC __text,
68 __TEXT __text, __DATA __data, or __DATA __bss.
69
70r, R
71
72 Read-only data object.
73
74t, T
75
76 Code (text) object.
77
78u
79
80 ELF: GNU unique symbol.
81
82U
83
84 Named object is undefined in this file.
85
86v
87
88 ELF: Undefined weak object. It is not a link failure if the object is not
89 defined.
90
91V
92
93 ELF: Defined weak object symbol. This definition will only be used if no
94 regular definitions exist in a link. If multiple weak definitions and no
95 regular definitons exist, one of the weak definitions will be used.
96
97w
98
99 Undefined weak symbol other than an ELF object symbol. It is not a link failure
100 if the symbol is not defined.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000101
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000102W
103
James Henderson3519d552019-06-24 09:53:02 +0000104 Defined weak symbol other than an ELF object symbol. This definition will only
105 be used if no regular definitions exist in a link. If multiple weak definitions
106 and no regular definitons exist, one of the weak definitions will be used.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000107
James Henderson3519d552019-06-24 09:53:02 +0000108\-
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000109
James Henderson3519d552019-06-24 09:53:02 +0000110 Mach-O: N_STAB symbol.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000111
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000112?
113
James Henderson3519d552019-06-24 09:53:02 +0000114 Something unrecognizable.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000115
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000116Because LLVM bitcode files typically contain objects that are not considered to
117have addresses until they are linked into an executable image or dynamically
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000118compiled "just-in-time", :program:`llvm-nm` does not print an address for any
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000119symbol in an LLVM bitcode file, even symbols which are defined in the bitcode
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000120file.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000121
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000122OPTIONS
123-------
124
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000125.. program:: llvm-nm
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000126
James Henderson2c5ff942019-06-24 10:50:49 +0000127.. option:: -B
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000128
James Henderson2c5ff942019-06-24 10:50:49 +0000129 Use BSD output format. Alias for ``--format=bsd``.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000130
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000131.. option:: --debug-syms, -a
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000132
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000133 Show all symbols, even debugger only.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000134
James Henderson2c5ff942019-06-24 10:50:49 +0000135.. option:: --defined-only, -U
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000136
James Henderson2c5ff942019-06-24 10:50:49 +0000137 Print only symbols defined in this file.
138
139.. option:: --demangle, -C
140
141 Demangle symbol names.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000142
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
James Henderson2c5ff942019-06-24 10:50:49 +0000149 Print only symbols whose definitions are external; that is, accessible from
150 other files.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000151
James Henderson2c5ff942019-06-24 10:50:49 +0000152.. option:: --format=<format>, -f
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000153
James Henderson5058ae02019-06-11 15:58:10 +0000154 Select an output format; *format* may be *sysv*, *posix*, *darwin*, or *bsd*.
155 The default is *bsd*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000156
James Henderson224410b2019-06-11 14:55:31 +0000157.. option:: --help, -h
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000158
159 Print a summary of command-line options and their meanings.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000160
James Henderson2c5ff942019-06-24 10:50:49 +0000161.. option:: --help-list
162
163 Print an uncategorized summary of command-line options and their meanings.
164
165.. option:: --just-symbol-name, -j
166
167 Print just the symbol names.
168
169.. option:: -m
170
171 Use Darwin format. Alias for ``--format=darwin``.
172
173.. option:: --no-demangle
174
175 Don't demangle symbol names. This is the default.
176
177.. option:: --no-llvm-bc
178
179 Disable the LLVM bitcode reader.
180
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000181.. option:: --no-sort, -p
182
183 Shows symbols in order encountered.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000184
James Henderson2c5ff942019-06-24 10:50:49 +0000185.. option:: --no-weak, -W
186
187 Don't print weak symbols.
188
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000189.. option:: --numeric-sort, -n, -v
190
191 Sort symbols by address.
192
James Henderson2c5ff942019-06-24 10:50:49 +0000193.. option:: --portability, -P
194
195 Use POSIX.2 output format. Alias for ``--format=posix``.
196
197.. option:: --print-armap, -M
198
199 Print the archive symbol table, in addition to the symbols.
200
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000201.. option:: --print-file-name, -A, -o
202
203 Precede each symbol with the file it came from.
204
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000205.. option:: --print-size, -S
206
James Henderson2c16bb82019-06-12 10:44:41 +0000207 Show symbol size as well as address (not applicable for Mach-O).
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000208
James Henderson2c5ff942019-06-24 10:50:49 +0000209.. option:: --radix=<RADIX>, -t
210
211 Specify the radix of the symbol address(es). Values accepted are *d* (decimal),
212 *x* (hexadecimal) and *o* (octal).
213
214.. option:: --reverse-sort, -r
215
216 Sort symbols in reverse order.
217
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000218.. option:: --size-sort
219
220 Sort symbols by size.
221
James Henderson2c5ff942019-06-24 10:50:49 +0000222.. option:: --special-syms
223
224 Ignored. For GNU compatibility only.
225
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000226.. option:: --undefined-only, -u
227
James Henderson2c5ff942019-06-24 10:50:49 +0000228 Print only undefined symbols.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000229
James Henderson2c5ff942019-06-24 10:50:49 +0000230.. option:: --version
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000231
James Henderson2c5ff942019-06-24 10:50:49 +0000232 Display the version of this program. Does not stack with other commands.
233
234.. option:: --without-aliases
235
236 Exclude aliases from the output.
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000237
James Henderson9485b262019-06-21 11:49:20 +0000238.. option:: @<FILE>
239
240 Read command-line options from response file `<FILE>`.
241
James Henderson2c5ff942019-06-24 10:50:49 +0000242MACH-O SPECIFIC OPTIONS
243-----------------------
244
245.. option:: --add-dyldinfo
246
247 Add symbols from the dyldinfo, if they are not already in the symbol table.
248 This is the default.
249
250.. option:: --arch=<arch1[,arch2,...]>
251
252 Dump the symbols from the specified architecture(s).
253
254.. option:: --dyldinfo-only
255
256 Dump only symbols from the dyldinfo.
257
258.. option:: --no-dyldinfo
259
260 Do not add any symbols from the dyldinfo.
261
262.. option:: -s=<segment section>
263
264 Dump only symbols from this segment and section name.
265
266.. option:: -x
267
268 Print symbol entry in hex.
269
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000270BUGS
271----
272
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000273 * :program:`llvm-nm` does not support the full set of arguments that GNU
274 :program:`nm` does.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000275
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000276EXIT STATUS
277-----------
278
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000279:program:`llvm-nm` exits with an exit code of zero.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000280
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000281SEE ALSO
282--------
283
James Henderson92b32a92019-06-27 15:18:15 +0000284:manpage:`llvm-ar(1)`, :manpage:`llvm-objdump(1)`, :manpage:`llvm-readelf(1)`,
285:manpage:`llvm-readobj(1)`