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