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