xref: /openbsd-src/gnu/llvm/llvm/docs/CommandGuide/llvm-nm.rst (revision 5a38ef86d0b61900239c7913d24a05e7b88a58f0)
1llvm-nm - list LLVM bitcode and object file's symbol table
2==========================================================
3
4.. program:: llvm-nm
5
6SYNOPSIS
7--------
8
9:program:`llvm-nm` [*options*] [*filenames...*]
10
11DESCRIPTION
12-----------
13
14The :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
16information about its provenance. If no filename is specified, *a.out* is used
17as the input. If *-* is used as a filename, :program:`llvm-nm` will read a file
18from its standard input stream.
19
20:program:`llvm-nm`'s default output format is the traditional BSD :program:`nm`
21output format. Each such output record consists of an (optional) 8-digit
22hexadecimal address, followed by a type code character, followed by a name, for
23each symbol. One record is printed per line; fields are separated by spaces.
24When the address is omitted, it is replaced by 8 spaces.
25
26The supported type code characters are as follows. Where both lower and
27upper-case characters are listed for the same meaning, a lower-case character
28represents a local symbol, whilst an upper-case character represents a global
29(external) symbol:
30
31a, A
32
33 Absolute symbol.
34
35b, B
36
37 Uninitialized data (bss) object.
38
39C
40
41 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 definitions 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.
99
100W
101
102 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 definitions exist, one of the weak definitions will be used.
105
106\-
107
108 Mach-O: N_STAB symbol.
109
110?
111
112 Something unrecognizable.
113
114Because LLVM bitcode files typically contain objects that are not considered to
115have addresses until they are linked into an executable image or dynamically
116compiled "just-in-time", :program:`llvm-nm` does not print an address for any
117symbol in an LLVM bitcode file, even symbols which are defined in the bitcode
118file.
119
120OPTIONS
121-------
122
123.. program:: llvm-nm
124
125.. option:: -B
126
127 Use BSD output format. Alias for ``--format=bsd``.
128
129.. option:: --debug-syms, -a
130
131 Show all symbols, even those usually suppressed.
132
133.. option:: --defined-only
134
135 Print only symbols defined in this file.
136
137.. option:: --demangle, -C
138
139 Demangle symbol names.
140
141.. option:: --dynamic, -D
142
143 Display dynamic symbols instead of normal symbols.
144
145.. option:: --extern-only, -g
146
147 Print only symbols whose definitions are external; that is, accessible from
148 other files.
149
150.. option:: --format=<format>, -f
151
152 Select an output format; *format* may be *sysv*, *posix*, *darwin*, *bsd* or
153 *just-symbols*.
154 The default is *bsd*.
155
156.. option:: --help, -h
157
158 Print a summary of command-line options and their meanings.
159
160.. option:: -j
161
162 Print just the symbol names. Alias for `--format=just-symbols``.
163
164.. option:: -m
165
166 Use Darwin format. Alias for ``--format=darwin``.
167
168.. option:: --no-demangle
169
170 Don't demangle symbol names. This is the default.
171
172.. option:: --no-llvm-bc
173
174 Disable the LLVM bitcode reader.
175
176.. option:: --no-sort, -p
177
178 Show symbols in the order encountered.
179
180.. option:: --no-weak
181
182 Don't print weak symbols.
183
184.. option:: --numeric-sort, -n, -v
185
186 Sort symbols by address.
187
188.. option:: --portability, -P
189
190 Use POSIX.2 output format.  Alias for ``--format=posix``.
191
192.. option:: --print-armap
193
194 Print the archive symbol table, in addition to the symbols.
195
196.. option:: --print-file-name, -A, -o
197
198 Precede each symbol with the file it came from.
199
200.. option:: --print-size, -S
201
202 Show symbol size as well as address (not applicable for Mach-O).
203
204.. option:: --quiet
205
206 Suppress 'no symbols' diagnostic.
207
208.. option:: --radix=<RADIX>, -t
209
210 Specify the radix of the symbol address(es). Values accepted are *d* (decimal),
211 *x* (hexadecimal) and *o* (octal).
212
213.. option:: --reverse-sort, -r
214
215 Sort symbols in reverse order.
216
217.. option:: --size-sort
218
219 Sort symbols by size.
220
221.. option:: --special-syms
222
223 Do not filter special symbols from the output.
224
225.. option:: --undefined-only, -u
226
227 Print only undefined symbols.
228
229.. option:: --version, -V
230
231 Display the version of the :program:`llvm-nm` executable, then exit. Does not
232 stack with other commands.
233
234.. option:: @<FILE>
235
236 Read command-line options from response file `<FILE>`.
237
238MACH-O SPECIFIC OPTIONS
239-----------------------
240
241.. option:: --add-dyldinfo
242
243 Add symbols from the dyldinfo, if they are not already in the symbol table.
244 This is the default.
245
246.. option:: --add-inlinedinfo
247
248 Add symbols from the inlined libraries, TBD file inputs only.
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
270BUGS
271----
272
273 * :program:`llvm-nm` does not support the full set of arguments that GNU
274   :program:`nm` does.
275
276EXIT STATUS
277-----------
278
279:program:`llvm-nm` exits with an exit code of zero.
280
281SEE ALSO
282--------
283
284:manpage:`llvm-ar(1)`, :manpage:`llvm-objdump(1)`, :manpage:`llvm-readelf(1)`,
285:manpage:`llvm-readobj(1)`
286