xref: /llvm-project/llvm/docs/CommandGuide/llvm-objdump.rst (revision 95062d74676b98a85e4d3db6628d239b15dbeb35)
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, PowerPC, 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:: --build-id=<string>
129
130  Look up the object using the given build ID, specified as a hexadecimal
131  string. The found object is handled as if it were an input filename.
132
133.. option:: -C, --demangle
134
135  Demangle symbol names in the output.
136
137.. option:: --debug-file-directory <path>
138
139  Provide a path to a directory with a `.build-id` subdirectory to search for
140  debug information for stripped binaries. Multiple instances of this argument
141  are searched in the order given.
142
143.. option:: --debuginfod, --no-debuginfod
144
145  Whether or not to try debuginfod lookups for debug binaries. Unless specified,
146  debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
147  and at least one server URL was provided by the environment variable
148  ``DEBUGINFOD_URLS``.
149
150.. option:: --debug-vars=<format>
151
152  Print the locations (in registers or memory) of source-level variables
153  alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
154  to ``unicode`` if omitted.
155
156.. option:: --debug-vars-indent=<width>
157
158  Distance to indent the source-level variable display, relative to the start
159  of the disassembly. Defaults to 52 characters.
160
161.. option:: -j, --section=<section1[,section2,...]>
162
163  Perform commands on the specified sections only. For Mach-O use
164  `segment,section` to specify the section name.
165
166.. option:: -l, --line-numbers
167
168  When disassembling, display source line numbers. Implies
169  :option:`--disassemble`.
170
171.. option:: -M, --disassembler-options=<opt1[,opt2,...]>
172
173  Pass target-specific disassembler options. Available options:
174
175  * ``reg-names-std``: ARM only (default). Print in ARM 's instruction set documentation, with r13/r14/r15 replaced by sp/lr/pc.
176  * ``reg-names-raw``: ARM only. Use r followed by the register number.
177  * ``no-aliases``: AArch64 and RISC-V only. Print raw instruction mnemonic instead of pseudo instruction mnemonic.
178  * ``numeric``: RISC-V only. Print raw register names instead of ABI mnemonic. (e.g. print x1 instead of ra)
179  * ``att``: x86 only (default). Print in the AT&T syntax.
180  * ``intel``: x86 only. Print in the intel syntax.
181
182
183.. option::  --disassembler-color=<mode>
184
185  Enable or disable disassembler color output.
186
187  * ``off``: Disable disassembler color output.
188  * ``on``: Enable disassembler color output.
189  * ``terminal``: Enable disassembler color output if the terminal supports it (default).
190
191.. option:: --mcpu=<cpu-name>
192
193  Target a specific CPU type for disassembly. Specify ``--mcpu=help`` to display
194  available CPUs.
195
196.. option:: --mattr=<a1,+a2,-a3,...>
197
198  Enable/disable target-specific attributes. Specify ``--mattr=help`` to display
199  the available attributes.
200
201.. option:: --no-leading-addr, --no-addresses
202
203  When disassembling, do not print leading addresses for instructions or inline
204  relocations.
205
206.. option:: --no-print-imm-hex
207
208  Do not use hex format for immediate values in disassembly output.
209
210.. option:: --no-show-raw-insn
211
212  When disassembling, do not print the raw bytes of each instruction.
213
214.. option:: --offloading
215
216  Display the content of the LLVM offloading section.
217
218.. option:: --prefix=<prefix>
219
220  When disassembling with the :option:`--source` option, prepend ``prefix`` to
221  absolute paths.
222
223.. option:: --prefix-strip=<level>
224
225  When disassembling with the :option:`--source` option, strip out ``level``
226  initial directories from absolute paths. This option has no effect without
227  :option:`--prefix`.
228
229.. option:: --print-imm-hex
230
231  Use hex format when printing immediate values in disassembly output (default).
232
233.. option:: -S, --source
234
235  When disassembling, display source interleaved with the disassembly. Implies
236  :option:`--disassemble`.
237
238.. option:: --show-all-symbols
239
240  Show all symbols during disassembly, even if multiple symbols are defined at
241  the same location.
242
243.. option:: --show-lma
244
245  Display the LMA column when dumping ELF section headers. Defaults to off
246  unless any section has different VMA and LMAs.
247
248.. option:: --start-address=<address>
249
250  When disassembling, only disassemble from the specified address.
251
252  When printing relocations, only print the relocations patching offsets from at least ``address``.
253
254  When printing symbols, only print symbols with a value of at least ``address``.
255
256.. option:: --stop-address=<address>
257
258  When disassembling, only disassemble up to, but not including the specified address.
259
260  When printing relocations, only print the relocations patching offsets up to ``address``.
261
262  When printing symbols, only print symbols with a value up to ``address``.
263
264.. option:: --symbolize-operands
265
266  When disassembling, symbolize a branch target operand to print a label instead of a real address.
267
268  When printing a PC-relative global symbol reference, print it as an offset from the leading symbol.
269
270  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.
271
272  Only works with PowerPC objects or X86 linked images.
273
274  Example:
275    A non-symbolized branch instruction with a local target and pc-relative memory access like
276
277  .. code-block:: none
278
279      cmp eax, dword ptr [rip + 4112]
280      jge 0x20117e <_start+0x25>
281
282  might become
283
284  .. code-block:: none
285
286     <L0>:
287       cmp eax, dword ptr <g>
288       jge	<L0>
289
290.. option:: --triple=<string>
291
292  Target triple to disassemble for, see ``--version`` for available targets.
293
294.. option:: -w, --wide
295
296  Ignored for compatibility with GNU objdump.
297
298.. option:: --x86-asm-syntax=<style>
299
300  Deprecated.
301  When used with :option:`--disassemble`, choose style of code to emit from
302  X86 backend. Supported values are:
303
304   .. option:: att
305
306    AT&T-style assembly
307
308   .. option:: intel
309
310    Intel-style assembly
311
312
313  The default disassembly style is **att**.
314
315.. option:: -z, --disassemble-zeroes
316
317  Do not skip blocks of zeroes when disassembling.
318
319.. option:: @<FILE>
320
321  Read command-line options and commands from response file `<FILE>`.
322
323MACH-O ONLY OPTIONS AND COMMANDS
324--------------------------------
325
326.. option:: --arch=<architecture>
327
328  Specify the architecture to disassemble. see ``--version`` for available
329  architectures.
330
331.. option:: --archive-member-offsets
332
333  Print the offset to each archive member for Mach-O archives (requires
334  :option:`--archive-headers`).
335
336.. option:: --bind
337
338  Display binding info
339
340.. option:: --data-in-code
341
342  Display the data in code table.
343
344.. option:: --dis-symname=<name>
345
346  Disassemble just the specified symbol's instructions.
347
348.. option:: --chained-fixups
349
350  Print chained fixup information.
351
352.. option:: --dyld-info
353
354  Print bind and rebase information used by dyld to resolve external
355  references in a final linked binary.
356
357.. option:: --dylibs-used
358
359  Display the shared libraries used for linked files.
360
361.. option:: --dsym=<string>
362
363  Use .dSYM file for debug info.
364
365.. option:: --dylib-id
366
367  Display the shared library's ID for dylib files.
368
369.. option:: --exports-trie
370
371  Display exported symbols.
372
373.. option:: --function-starts [=<addrs|names|both>]
374
375  Print the function starts table for Mach-O objects. Either ``addrs``
376  (default) to print only the addresses of functions, ``names`` to print only
377  the names of the functions (when available), or ``both`` to print the
378  names beside the addresses.
379
380.. option:: -g
381
382  Print line information from debug info if available.
383
384.. option:: --full-leading-addr
385
386  Print the full leading address when disassembling.
387
388.. option:: --indirect-symbols
389
390  Display the indirect symbol table.
391
392.. option:: --info-plist
393
394  Display the info plist section as strings.
395
396.. option:: --lazy-bind
397
398  Display lazy binding info.
399
400.. option:: --link-opt-hints
401
402  Display the linker optimization hints.
403
404.. option:: -m, --macho
405
406  Use Mach-O specific object file parser. Commands and other options may behave
407  differently when used with ``--macho``.
408
409.. option:: --no-leading-headers
410
411  Do not print any leading headers.
412
413.. option:: --no-symbolic-operands
414
415  Do not print symbolic operands when disassembling.
416
417.. option:: --non-verbose
418
419  Display the information for Mach-O objects in non-verbose or numeric form.
420
421.. option:: --objc-meta-data
422
423  Display the Objective-C runtime meta data.
424
425.. option:: --private-header
426
427  Display only the first format specific file header.
428
429.. option:: --rebase
430
431  Display rebasing information.
432
433.. option:: --rpaths
434
435  Display runtime search paths for the binary.
436
437.. option:: --universal-headers
438
439  Display universal headers.
440
441.. option:: --weak-bind
442
443  Display weak binding information.
444
445XCOFF ONLY OPTIONS AND COMMANDS
446---------------------------------
447
448.. option:: --symbol-description
449
450  Add symbol description to disassembly output.
451
452.. option:: --traceback-table
453
454  Decode traceback table in disassembly output. Implies :option:`--disassemble`.
455
456BUGS
457----
458
459To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objdump/>.
460
461SEE ALSO
462--------
463
464:manpage:`llvm-nm(1)`, :manpage:`llvm-otool(1)`, :manpage:`llvm-readelf(1)`,
465:manpage:`llvm-readobj(1)`
466