blob: aa58a3f3884ca815c35367a7fc1b455bbfce4e31 [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
James Henderson65d75112019-07-09 10:40:50 +000014The :program:`llvm-nm` utility lists the names of symbols from LLVM bitcode
15files, object files, and archives. Each symbol is listed along with some simple
Alex Brachet60c81352019-07-12 10:20:01 +000016information about its provenance. If no filename is specified, or *-* is used as
17a filename, :program:`llvm-nm` will read a file from its standard 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`
James Henderson65d75112019-07-09 10:40:50 +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
James Henderson65d75112019-07-09 10:40:50 +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 Henderson65d75112019-07-09 10:40:50 +000025The supported type code characters are as follows. Where both lower and
26upper-case characters are listed for the same meaning, a lower-case character
27represents a local symbol, whilst an upper-case character represents a global
28(external) symbol:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000029
James Henderson3519d552019-06-24 09:53:02 +000030a, A
31
32 Absolute symbol.
33
34b, B
35
36 Unitialized data (bss) object.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000037
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000038C
39
James Henderson3519d552019-06-24 09:53:02 +000040 Common symbol. Multiple definitions link together into one definition.
41
42d, D
43
44 Writable data object.
45
46i, I
47
48 COFF: .idata symbol or symbol in a section with IMAGE_SCN_LNK_INFO set.
49
50n
51
52 ELF: local symbol from non-alloc section.
53
54 COFF: debug symbol.
55
56N
57
58 ELF: debug section symbol, or global symbol from non-alloc section.
59
60s, S
61
62 COFF: section symbol.
63
64 Mach-O: absolute symbol or symbol from a section other than __TEXT_EXEC __text,
65 __TEXT __text, __DATA __data, or __DATA __bss.
66
67r, R
68
69 Read-only data object.
70
71t, T
72
73 Code (text) object.
74
75u
76
77 ELF: GNU unique symbol.
78
79U
80
81 Named object is undefined in this file.
82
83v
84
85 ELF: Undefined weak object. It is not a link failure if the object is not
86 defined.
87
88V
89
90 ELF: Defined weak object symbol. This definition will only be used if no
91 regular definitions exist in a link. If multiple weak definitions and no
92 regular definitons exist, one of the weak definitions will be used.
93
94w
95
96 Undefined weak symbol other than an ELF object symbol. It is not a link failure
97 if the symbol is not defined.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000098
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000099W
100
James Henderson3519d552019-06-24 09:53:02 +0000101 Defined weak symbol other than an ELF object symbol. This definition will only
102 be used if no regular definitions exist in a link. If multiple weak definitions
103 and no regular definitons exist, one of the weak definitions will be used.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000104
James Henderson3519d552019-06-24 09:53:02 +0000105\-
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000106
James Henderson3519d552019-06-24 09:53:02 +0000107 Mach-O: N_STAB symbol.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000108
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000109?
110
James Henderson3519d552019-06-24 09:53:02 +0000111 Something unrecognizable.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000112
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000113Because LLVM bitcode files typically contain objects that are not considered to
114have addresses until they are linked into an executable image or dynamically
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000115compiled "just-in-time", :program:`llvm-nm` does not print an address for any
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000116symbol in an LLVM bitcode file, even symbols which are defined in the bitcode
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000117file.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000118
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000119OPTIONS
120-------
121
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000122.. program:: llvm-nm
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000123
James Henderson2c5ff942019-06-24 10:50:49 +0000124.. option:: -B
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000125
James Henderson2c5ff942019-06-24 10:50:49 +0000126 Use BSD output format. Alias for ``--format=bsd``.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000127
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000128.. option:: --debug-syms, -a
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000129
James Henderson65d75112019-07-09 10:40:50 +0000130 Show all symbols, even those usually suppressed.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000131
James Henderson2c5ff942019-06-24 10:50:49 +0000132.. option:: --defined-only, -U
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000133
James Henderson2c5ff942019-06-24 10:50:49 +0000134 Print only symbols defined in this file.
135
136.. option:: --demangle, -C
137
138 Demangle symbol names.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000139
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000140.. option:: --dynamic, -D
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000141
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000142 Display dynamic symbols instead of normal symbols.
143
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000144.. option:: --extern-only, -g
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000145
James Henderson2c5ff942019-06-24 10:50:49 +0000146 Print only symbols whose definitions are external; that is, accessible from
147 other files.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000148
James Henderson2c5ff942019-06-24 10:50:49 +0000149.. option:: --format=<format>, -f
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000150
James Henderson5058ae02019-06-11 15:58:10 +0000151 Select an output format; *format* may be *sysv*, *posix*, *darwin*, or *bsd*.
152 The default is *bsd*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000153
James Henderson224410b2019-06-11 14:55:31 +0000154.. option:: --help, -h
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000155
156 Print a summary of command-line options and their meanings.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000157
James Henderson2c5ff942019-06-24 10:50:49 +0000158.. option:: --help-list
159
160 Print an uncategorized summary of command-line options and their meanings.
161
162.. option:: --just-symbol-name, -j
163
164 Print just the symbol names.
165
166.. option:: -m
167
168 Use Darwin format. Alias for ``--format=darwin``.
169
170.. option:: --no-demangle
171
172 Don't demangle symbol names. This is the default.
173
174.. option:: --no-llvm-bc
175
176 Disable the LLVM bitcode reader.
177
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000178.. option:: --no-sort, -p
179
James Henderson73e33362019-07-15 16:40:34 +0000180 Show symbols in the order encountered.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000181
James Henderson2c5ff942019-06-24 10:50:49 +0000182.. option:: --no-weak, -W
183
184 Don't print weak symbols.
185
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000186.. option:: --numeric-sort, -n, -v
187
188 Sort symbols by address.
189
James Henderson2c5ff942019-06-24 10:50:49 +0000190.. option:: --portability, -P
191
192 Use POSIX.2 output format. Alias for ``--format=posix``.
193
194.. option:: --print-armap, -M
195
196 Print the archive symbol table, in addition to the symbols.
197
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000198.. option:: --print-file-name, -A, -o
199
200 Precede each symbol with the file it came from.
201
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000202.. option:: --print-size, -S
203
James Henderson2c16bb82019-06-12 10:44:41 +0000204 Show symbol size as well as address (not applicable for Mach-O).
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000205
James Henderson2c5ff942019-06-24 10:50:49 +0000206.. option:: --radix=<RADIX>, -t
207
208 Specify the radix of the symbol address(es). Values accepted are *d* (decimal),
209 *x* (hexadecimal) and *o* (octal).
210
211.. option:: --reverse-sort, -r
212
213 Sort symbols in reverse order.
214
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000215.. option:: --size-sort
216
217 Sort symbols by size.
218
James Henderson2c5ff942019-06-24 10:50:49 +0000219.. option:: --special-syms
220
221 Ignored. For GNU compatibility only.
222
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000223.. option:: --undefined-only, -u
224
James Henderson2c5ff942019-06-24 10:50:49 +0000225 Print only undefined symbols.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000226
James Henderson2c5ff942019-06-24 10:50:49 +0000227.. option:: --version
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000228
James Henderson2c5ff942019-06-24 10:50:49 +0000229 Display the version of this program. Does not stack with other commands.
230
231.. option:: --without-aliases
232
233 Exclude aliases from the output.
Hemant Kulkarni5e005a12016-02-10 17:51:39 +0000234
James Henderson9485b262019-06-21 11:49:20 +0000235.. option:: @<FILE>
236
237 Read command-line options from response file `<FILE>`.
238
James Henderson2c5ff942019-06-24 10:50:49 +0000239MACH-O SPECIFIC OPTIONS
240-----------------------
241
242.. option:: --add-dyldinfo
243
244 Add symbols from the dyldinfo, if they are not already in the symbol table.
245 This is the default.
246
247.. option:: --arch=<arch1[,arch2,...]>
248
249 Dump the symbols from the specified architecture(s).
250
251.. option:: --dyldinfo-only
252
253 Dump only symbols from the dyldinfo.
254
255.. option:: --no-dyldinfo
256
257 Do not add any symbols from the dyldinfo.
258
259.. option:: -s=<segment section>
260
261 Dump only symbols from this segment and section name.
262
263.. option:: -x
264
265 Print symbol entry in hex.
266
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000267BUGS
268----
269
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000270 * :program:`llvm-nm` does not support the full set of arguments that GNU
271 :program:`nm` does.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000272
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000273EXIT STATUS
274-----------
275
Michael J. Spencer838e5ad2012-06-06 23:34:10 +0000276:program:`llvm-nm` exits with an exit code of zero.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000277
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000278SEE ALSO
279--------
280
James Henderson92b32a92019-06-27 15:18:15 +0000281:manpage:`llvm-ar(1)`, :manpage:`llvm-objdump(1)`, :manpage:`llvm-readelf(1)`,
282:manpage:`llvm-readobj(1)`