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