xref: /llvm-project/llvm/docs/CommandGuide/llvm-objdump.rst (revision ad92a3db2e43f1fcac65a1a7949dd24c855d7002)
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 for instructions or inline
190  relocations.
191
192.. option:: --no-print-imm-hex
193
194  Do not use hex format for immediate values in disassembly output (default).
195
196.. option:: --no-show-raw-insn
197
198  When disassembling, do not print the raw bytes of each instruction.
199
200.. option:: --offloading
201
202  Display the content of the LLVM offloading section.
203
204.. option:: --prefix=<prefix>
205
206  When disassembling with the :option:`--source` option, prepend ``prefix`` to
207  absolute paths.
208
209.. option:: --prefix-strip=<level>
210
211  When disassembling with the :option:`--source` option, strip out ``level``
212  initial directories from absolute paths. This option has no effect without
213  :option:`--prefix`.
214
215.. option:: --print-imm-hex
216
217  Use hex format when printing immediate values in disassembly output.
218
219.. option:: -S, --source
220
221  When disassembling, display source interleaved with the disassembly. Implies
222  :option:`--disassemble`.
223
224.. option:: --show-lma
225
226  Display the LMA column when dumping ELF section headers. Defaults to off
227  unless any section has different VMA and LMAs.
228
229.. option:: --start-address=<address>
230
231  When disassembling, only disassemble from the specified address.
232
233  When printing relocations, only print the relocations patching offsets from at least ``address``.
234
235  When printing symbols, only print symbols with a value of at least ``address``.
236
237.. option:: --stop-address=<address>
238
239  When disassembling, only disassemble up to, but not including the specified address.
240
241  When printing relocations, only print the relocations patching offsets up to ``address``.
242
243  When printing symbols, only print symbols with a value up to ``address``.
244
245.. option:: --symbolize-operands
246
247  When disassembling, symbolize a branch target operand to print a label instead of a real address.
248
249  When printing a PC-relative global symbol reference, print it as an offset from the leading symbol.
250
251  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.
252
253  Only works with PowerPC objects or X86 linked images.
254
255  Example:
256    A non-symbolized branch instruction with a local target and pc-relative memory access like
257
258  .. code-block:: none
259
260      cmp eax, dword ptr [rip + 4112]
261      jge 0x20117e <_start+0x25>
262
263  might become
264
265  .. code-block:: none
266
267     <L0>:
268       cmp eax, dword ptr <g>
269       jge	<L0>
270
271.. option:: --triple=<string>
272
273  Target triple to disassemble for, see ``--version`` for available targets.
274
275.. option:: -w, --wide
276
277  Ignored for compatibility with GNU objdump.
278
279.. option:: --x86-asm-syntax=<style>
280
281  Deprecated.
282  When used with :option:`--disassemble`, choose style of code to emit from
283  X86 backend. Supported values are:
284
285   .. option:: att
286
287    AT&T-style assembly
288
289   .. option:: intel
290
291    Intel-style assembly
292
293
294  The default disassembly style is **att**.
295
296.. option:: -z, --disassemble-zeroes
297
298  Do not skip blocks of zeroes when disassembling.
299
300.. option:: @<FILE>
301
302  Read command-line options and commands from response file `<FILE>`.
303
304MACH-O ONLY OPTIONS AND COMMANDS
305--------------------------------
306
307.. option:: --arch=<architecture>
308
309  Specify the architecture to disassemble. see ``--version`` for available
310  architectures.
311
312.. option:: --archive-member-offsets
313
314  Print the offset to each archive member for Mach-O archives (requires
315  :option:`--archive-headers`).
316
317.. option:: --bind
318
319  Display binding info
320
321.. option:: --data-in-code
322
323  Display the data in code table.
324
325.. option:: --dis-symname=<name>
326
327  Disassemble just the specified symbol's instructions.
328
329.. option:: --chained-fixups
330
331  Print chained fixup information.
332
333.. option:: --dyld-info
334
335  Print bind and rebase information used by dyld to resolve external
336  references in a final linked binary.
337
338.. option:: --dylibs-used
339
340  Display the shared libraries used for linked files.
341
342.. option:: --dsym=<string>
343
344  Use .dSYM file for debug info.
345
346.. option:: --dylib-id
347
348  Display the shared library's ID for dylib files.
349
350.. option:: --exports-trie
351
352  Display exported symbols.
353
354.. option:: --function-starts
355
356  Print the function starts table for Mach-O objects.
357
358.. option:: -g
359
360  Print line information from debug info if available.
361
362.. option:: --full-leading-addr
363
364  Print the full leading address when disassembling.
365
366.. option:: --indirect-symbols
367
368  Display the indirect symbol table.
369
370.. option:: --info-plist
371
372  Display the info plist section as strings.
373
374.. option:: --lazy-bind
375
376  Display lazy binding info.
377
378.. option:: --link-opt-hints
379
380  Display the linker optimization hints.
381
382.. option:: -m, --macho
383
384  Use Mach-O specific object file parser. Commands and other options may behave
385  differently when used with ``--macho``.
386
387.. option:: --no-leading-headers
388
389  Do not print any leading headers.
390
391.. option:: --no-symbolic-operands
392
393  Do not print symbolic operands when disassembling.
394
395.. option:: --non-verbose
396
397  Display the information for Mach-O objects in non-verbose or numeric form.
398
399.. option:: --objc-meta-data
400
401  Display the Objective-C runtime meta data.
402
403.. option:: --private-header
404
405  Display only the first format specific file header.
406
407.. option:: --rebase
408
409  Display rebasing information.
410
411.. option:: --rpaths
412
413  Display runtime search paths for the binary.
414
415.. option:: --universal-headers
416
417  Display universal headers.
418
419.. option:: --weak-bind
420
421  Display weak binding information.
422
423XCOFF ONLY OPTIONS AND COMMANDS
424---------------------------------
425
426.. option:: --symbol-description
427
428  Add symbol description to disassembly output.
429
430BUGS
431----
432
433To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objdump/>.
434
435SEE ALSO
436--------
437
438:manpage:`llvm-nm(1)`, :manpage:`llvm-otool(1)`, :manpage:`llvm-readelf(1)`,
439:manpage:`llvm-readobj(1)`
440