xref: /llvm-project/llvm/docs/CommandGuide/llvm-objdump.rst (revision d033ece0c985d3f89c261d030ff2ff1d9c58bbc6)
1llvm-objdump - LLVM's object file dumper
2========================================
3
4.. program:: llvm-objdump
5
6SYNOPSIS
7--------
8
9:program:`llvm-objdump` [*commands*] [*options*] [*filenames...*]
10
11DESCRIPTION
12-----------
13The :program:`llvm-objdump` utility prints the contents of object files and
14final linked images named on the command line. If no file name is specified,
15:program:`llvm-objdump` will attempt to read from *a.out*. If *-* is used as a
16file name, :program:`llvm-objdump` will process a file on its standard input
17stream.
18
19COMMANDS
20--------
21At least one of the following commands are required, and some commands can be
22combined with other commands:
23
24.. option:: -a, --archive-headers
25
26  Display the information contained within an archive's headers.
27
28.. option:: -d, --disassemble
29
30  Disassemble all executable sections found in the input files. On some
31  architectures (AArch64, PPC64, x86), all known instructions are disassembled by
32  default. On the others, :option:`--mcpu` or :option:`--mattr` is needed to
33  enable some instruction sets. Disabled instructions are displayed as
34  ``<unknown>``.
35
36.. option:: -D, --disassemble-all
37
38  Disassemble all sections found in the input files.
39
40.. option:: --disassemble-symbols=<symbol1[,symbol2,...]>
41
42  Disassemble only the specified symbols. Takes demangled symbol names when
43  :option:`--demangle` is specified, otherwise takes mangled symbol names.
44  Implies :option:`--disassemble`.
45
46.. option:: --dwarf=<value>
47
48  Dump the specified DWARF debug sections. The supported values are:
49
50  `frames` - .debug_frame
51
52.. option:: -f, --file-headers
53
54  Display the contents of the overall file header.
55
56.. option:: --fault-map-section
57
58  Display the content of the fault map section.
59
60.. option:: -h, --headers, --section-headers
61
62  Display summaries of the headers for each section.
63
64.. option:: --help
65
66  Display usage information and exit. Does not stack with other commands.
67
68.. option:: -p, --private-headers
69
70  Display format-specific file headers.
71
72.. option:: -r, --reloc
73
74  Display the relocation entries in the file.
75
76.. option:: -R, --dynamic-reloc
77
78  Display the dynamic relocation entries in the file.
79
80.. option:: --raw-clang-ast
81
82  Dump the raw binary contents of the clang AST section.
83
84.. option:: -s, --full-contents
85
86  Display the contents of each section.
87
88.. option:: -t, --syms
89
90  Display the symbol table.
91
92.. option:: -T, --dynamic-syms
93
94  Display the contents of the dynamic symbol table.
95
96.. option:: -u, --unwind-info
97
98  Display the unwind info of the input(s).
99
100  This operation is only currently supported for COFF and Mach-O object files.
101
102.. option:: -v, --version
103
104  Display the version of the :program:`llvm-objdump` executable. Does not stack
105  with other commands.
106
107.. option:: -x, --all-headers
108
109  Display all available header information. Equivalent to specifying
110  :option:`--archive-headers`, :option:`--file-headers`,
111  :option:`--private-headers`, :option:`--reloc`, :option:`--section-headers`,
112  and :option:`--syms`.
113
114OPTIONS
115-------
116:program:`llvm-objdump` supports the following options:
117
118.. option:: --adjust-vma=<offset>
119
120  Increase the displayed address in disassembly or section header printing by
121  the specified offset.
122
123.. option:: --arch-name=<string>
124
125  Specify the target architecture when disassembling. Use :option:`--version`
126  for a list of available targets.
127
128.. option:: -C, --demangle
129
130  Demangle symbol names in the output.
131
132.. option:: --debug-file-directory <path>
133
134  Provide a path to a directory with a `.build-id` subdirectory to search for
135  debug information for stripped binaries. Multiple instances of this argument
136  are searched in the order given.
137
138.. option:: --debuginfod, --no-debuginfod
139
140  Whether or not to try debuginfod lookups for debug binaries. Unless specified,
141  debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
142  and at least one server URL was provided by the environment variable
143  ``DEBUGINFOD_URLS``.
144
145.. option:: --debug-vars=<format>
146
147  Print the locations (in registers or memory) of source-level variables
148  alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
149  to ``unicode`` if omitted.
150
151.. option:: --debug-vars-indent=<width>
152
153  Distance to indent the source-level variable display, relative to the start
154  of the disassembly. Defaults to 52 characters.
155
156.. option:: -j, --section=<section1[,section2,...]>
157
158  Perform commands on the specified sections only. For Mach-O use
159  `segment,section` to specify the section name.
160
161.. option:: -l, --line-numbers
162
163  When disassembling, display source line numbers. Implies
164  :option:`--disassemble`.
165
166.. option:: -M, --disassembler-options=<opt1[,opt2,...]>
167
168  Pass target-specific disassembler options. Available options:
169
170  * ``reg-names-std``: ARM only (default). Print in ARM 's instruction set documentation, with r13/r14/r15 replaced by sp/lr/pc.
171  * ``reg-names-raw``: ARM only. Use r followed by the register number.
172  * ``no-aliases``: AArch64 and RISC-V only. Print raw instruction mnemonic instead of pseudo instruction mnemonic.
173  * ``numeric``: RISC-V only. Print raw register names instead of ABI mnemonic. (e.g. print x1 instead of ra)
174  * ``att``: x86 only (default). Print in the AT&T syntax.
175  * ``intel``: x86 only. Print in the intel syntax.
176
177.. option:: --mcpu=<cpu-name>
178
179  Target a specific CPU type for disassembly. Specify ``--mcpu=help`` to display
180  available CPUs.
181
182.. option:: --mattr=<a1,+a2,-a3,...>
183
184  Enable/disable target-specific attributes. Specify ``--mattr=help`` to display
185  the available attributes.
186
187.. option:: --no-leading-addr
188
189  When disassembling, do not print leading addresses.
190
191.. option:: --no-print-imm-hex
192
193  Do not use hex format for immediate values in disassembly output (default).
194
195.. option:: --no-show-raw-insn
196
197  When disassembling, do not print the raw bytes of each instruction.
198
199.. option:: --offloading
200
201  Display the content of the LLVM offloading section.
202
203.. option:: --prefix=<prefix>
204
205  When disassembling with the :option:`--source` option, prepend ``prefix`` to
206  absolute paths.
207
208.. option:: --prefix-strip=<level>
209
210  When disassembling with the :option:`--source` option, strip out ``level``
211  initial directories from absolute paths. This option has no effect without
212  :option:`--prefix`.
213
214.. option:: --print-imm-hex
215
216  Use hex format when printing immediate values in disassembly output.
217
218.. option:: -S, --source
219
220  When disassembling, display source interleaved with the disassembly. Implies
221  :option:`--disassemble`.
222
223.. option:: --show-lma
224
225  Display the LMA column when dumping ELF section headers. Defaults to off
226  unless any section has different VMA and LMAs.
227
228.. option:: --start-address=<address>
229
230  When disassembling, only disassemble from the specified address.
231
232  When printing relocations, only print the relocations patching offsets from at least ``address``.
233
234  When printing symbols, only print symbols with a value of at least ``address``.
235
236.. option:: --stop-address=<address>
237
238  When disassembling, only disassemble up to, but not including the specified address.
239
240  When printing relocations, only print the relocations patching offsets up to ``address``.
241
242  When printing symbols, only print symbols with a value up to ``address``.
243
244.. option:: --symbolize-operands
245
246  When disassembling, symbolize a branch target operand to print a label instead of a real address.
247
248  When printing a PC-relative global symbol reference, print it as an offset from the leading symbol.
249
250  When a bb-address-map section is present (i.e., the object file is built with ``-fbasic-block-sections=labels``), labels are retrieved from that section instead.
251
252  Only works with PowerPC objects or X86 linked images.
253
254  Example:
255    A non-symbolized branch instruction with a local target and pc-relative memory access like
256
257  .. code-block:: none
258
259      cmp eax, dword ptr [rip + 4112]
260      jge 0x20117e <_start+0x25>
261
262  might become
263
264  .. code-block:: none
265
266     <L0>:
267       cmp eax, dword ptr <g>
268       jge	<L0>
269
270.. option:: --triple=<string>
271
272  Target triple to disassemble for, see ``--version`` for available targets.
273
274.. option:: -w, --wide
275
276  Ignored for compatibility with GNU objdump.
277
278.. option:: --x86-asm-syntax=<style>
279
280  Deprecated.
281  When used with :option:`--disassemble`, choose style of code to emit from
282  X86 backend. Supported values are:
283
284   .. option:: att
285
286    AT&T-style assembly
287
288   .. option:: intel
289
290    Intel-style assembly
291
292
293  The default disassembly style is **att**.
294
295.. option:: -z, --disassemble-zeroes
296
297  Do not skip blocks of zeroes when disassembling.
298
299.. option:: @<FILE>
300
301  Read command-line options and commands from response file `<FILE>`.
302
303MACH-O ONLY OPTIONS AND COMMANDS
304--------------------------------
305
306.. option:: --arch=<architecture>
307
308  Specify the architecture to disassemble. see ``--version`` for available
309  architectures.
310
311.. option:: --archive-member-offsets
312
313  Print the offset to each archive member for Mach-O archives (requires
314  :option:`--archive-headers`).
315
316.. option:: --bind
317
318  Display binding info
319
320.. option:: --data-in-code
321
322  Display the data in code table.
323
324.. option:: --dis-symname=<name>
325
326  Disassemble just the specified symbol's instructions.
327
328.. option:: --chained-fixups
329
330  Print chained fixup information.
331
332.. option:: --dyld-info
333
334  Print bind and rebase information used by dyld to resolve external
335  references in a final linked binary.
336
337.. option:: --dylibs-used
338
339  Display the shared libraries used for linked files.
340
341.. option:: --dsym=<string>
342
343  Use .dSYM file for debug info.
344
345.. option:: --dylib-id
346
347  Display the shared library's ID for dylib files.
348
349.. option:: --exports-trie
350
351  Display exported symbols.
352
353.. option:: --function-starts
354
355  Print the function starts table for Mach-O objects.
356
357.. option:: -g
358
359  Print line information from debug info if available.
360
361.. option:: --full-leading-addr
362
363  Print the full leading address when disassembling.
364
365.. option:: --indirect-symbols
366
367  Display the indirect symbol table.
368
369.. option:: --info-plist
370
371  Display the info plist section as strings.
372
373.. option:: --lazy-bind
374
375  Display lazy binding info.
376
377.. option:: --link-opt-hints
378
379  Display the linker optimization hints.
380
381.. option:: -m, --macho
382
383  Use Mach-O specific object file parser. Commands and other options may behave
384  differently when used with ``--macho``.
385
386.. option:: --no-leading-headers
387
388  Do not print any leading headers.
389
390.. option:: --no-symbolic-operands
391
392  Do not print symbolic operands when disassembling.
393
394.. option:: --non-verbose
395
396  Display the information for Mach-O objects in non-verbose or numeric form.
397
398.. option:: --objc-meta-data
399
400  Display the Objective-C runtime meta data.
401
402.. option:: --private-header
403
404  Display only the first format specific file header.
405
406.. option:: --rebase
407
408  Display rebasing information.
409
410.. option:: --rpaths
411
412  Display runtime search paths for the binary.
413
414.. option:: --universal-headers
415
416  Display universal headers.
417
418.. option:: --weak-bind
419
420  Display weak binding information.
421
422XCOFF ONLY OPTIONS AND COMMANDS
423---------------------------------
424
425.. option:: --symbol-description
426
427  Add symbol description to disassembly output.
428
429BUGS
430----
431
432To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objdump/>.
433
434SEE ALSO
435--------
436
437:manpage:`llvm-nm(1)`, :manpage:`llvm-otool(1)`, :manpage:`llvm-readelf(1)`,
438:manpage:`llvm-readobj(1)`
439