aboutsummaryrefslogtreecommitdiff
path: root/llvm/docs/CommandGuide/llvm-objdump.rst
blob: c9f03796942872cde2745d446d2ea06f21a4a66e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
llvm-objdump - LLVM's object file dumper
========================================

.. program:: llvm-objdump

SYNOPSIS
--------

:program:`llvm-objdump` [*commands*] [*options*] [*filenames...*]

DESCRIPTION
-----------
The :program:`llvm-objdump` utility prints the contents of object files and
final linked images named on the command line. If no file name is specified,
:program:`llvm-objdump` will attempt to read from *a.out*. If *-* is used as a
file name, :program:`llvm-objdump` will process a file on its standard input
stream.

COMMANDS
--------
At least one of the following commands are required, and some commands can be
combined with other commands:

.. option:: -a, --archive-headers

  Display the information contained within an archive's headers.

.. option:: -d, --disassemble

  Disassemble all executable sections found in the input files. On some
  architectures (AArch64, PowerPC, x86), all known instructions are disassembled by
  default. On the others, :option:`--mcpu` or :option:`--mattr` is needed to
  enable some instruction sets. Disabled instructions are displayed as
  ``<unknown>``.

.. option:: -D, --disassemble-all

  Disassemble all sections found in the input files.

.. option:: --disassemble-symbols=<symbol1[,symbol2,...]>

  Disassemble only the specified symbols. Takes demangled symbol names when
  :option:`--demangle` is specified, otherwise takes mangled symbol names.
  Implies :option:`--disassemble`.

.. option:: --dwarf=<value>

  Dump the specified DWARF debug sections. The supported values are:

  `frames` - .debug_frame

.. option:: -f, --file-headers

  Display the contents of the overall file header.

.. option:: --fault-map-section

  Display the content of the fault map section.

.. option:: -h, --headers, --section-headers

  Display summaries of the headers for each section.

.. option:: --help

  Display usage information and exit. Does not stack with other commands.

.. option:: -p, --private-headers

  Display format-specific file headers.

.. option:: -r, --reloc

  Display the relocation entries in the file.

.. option:: -R, --dynamic-reloc

  Display the dynamic relocation entries in the file.

.. option:: --raw-clang-ast

  Dump the raw binary contents of the clang AST section.

.. option:: -s, --full-contents

  Display the contents of each section.

.. option:: -t, --syms

  Display the symbol table.

.. option:: -T, --dynamic-syms

  Display the contents of the dynamic symbol table.

.. option:: -u, --unwind-info

  Display the unwind info of the input(s).

  This operation is only currently supported for COFF and Mach-O object files.

.. option:: -v, --version

  Display the version of the :program:`llvm-objdump` executable. Does not stack
  with other commands.

.. option:: -x, --all-headers

  Display all available header information. Equivalent to specifying
  :option:`--archive-headers`, :option:`--file-headers`,
  :option:`--private-headers`, :option:`--reloc`, :option:`--section-headers`,
  and :option:`--syms`.

OPTIONS
-------
:program:`llvm-objdump` supports the following options:

.. option:: --adjust-vma=<offset>

  Increase the displayed address in disassembly or section header printing by
  the specified offset.

.. option:: --arch-name=<string>

  Specify the target architecture when disassembling. Use :option:`--version`
  for a list of available targets.

.. option:: --build-id=<string>

  Look up the object using the given build ID, specified as a hexadecimal
  string. The found object is handled as if it were an input filename.

.. option:: -C, --demangle

  Demangle symbol names in the output.

.. option:: --debug-file-directory <path>

  Provide a path to a directory with a `.build-id` subdirectory to search for
  debug information for stripped binaries. Multiple instances of this argument
  are searched in the order given.

.. option:: --debuginfod, --no-debuginfod

  Whether or not to try debuginfod lookups for debug binaries. Unless specified,
  debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
  and at least one server URL was provided by the environment variable
  ``DEBUGINFOD_URLS``.

.. option:: --debug-vars=<format>

  Print the locations (in registers or memory) of source-level variables
  alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
  to ``unicode`` if omitted.

.. option:: --debug-vars-indent=<width>

  Distance to indent the source-level variable display, relative to the start
  of the disassembly. Defaults to 52 characters.

.. option:: -j, --section=<section1[,section2,...]>

  Perform commands on the specified sections only. For Mach-O use
  `segment,section` to specify the section name.

.. option:: -l, --line-numbers

  When disassembling, display source line numbers. Implies
  :option:`--disassemble`.

.. option:: -M, --disassembler-options=<opt1[,opt2,...]>

  Pass target-specific disassembler options. Available options:

  * ``reg-names-std``: ARM only (default). Print in ARM 's instruction set documentation, with r13/r14/r15 replaced by sp/lr/pc.
  * ``reg-names-raw``: ARM only. Use r followed by the register number.
  * ``no-aliases``: AArch64 and RISC-V only. Print raw instruction mnemonic instead of pseudo instruction mnemonic.
  * ``numeric``: RISC-V only. Print raw register names instead of ABI mnemonic. (e.g. print x1 instead of ra)
  * ``att``: x86 only (default). Print in the AT&T syntax.
  * ``intel``: x86 only. Print in the intel syntax.


.. option::  --disassembler-color=<mode>

  Enable or disable disassembler color output.

  * ``off``: Disable disassembler color output.
  * ``on``: Enable disassembler color output.
  * ``terminal``: Enable disassembler color output if the terminal supports it (default).

.. option:: --mcpu=<cpu-name>

  Target a specific CPU type for disassembly. Specify ``--mcpu=help`` to display
  available CPUs.

.. option:: --mattr=<a1,+a2,-a3,...>

  Enable/disable target-specific attributes. Specify ``--mattr=help`` to display
  the available attributes.

.. option:: -mllvm <arg>

   Specify an argument to forward to LLVM's CommandLine library.

.. option:: --no-leading-addr, --no-addresses

  When disassembling, do not print leading addresses for instructions or inline
  relocations.

.. option:: --no-print-imm-hex

  Do not use hex format for immediate values in disassembly output.

.. option:: --no-show-raw-insn

  When disassembling, do not print the raw bytes of each instruction.

.. option:: --offloading

  Display the content of the LLVM offloading sections and HIP offload bundles.

.. option:: --prefix=<prefix>

  When disassembling with the :option:`--source` option, prepend ``prefix`` to
  absolute paths.

.. option:: --prefix-strip=<level>

  When disassembling with the :option:`--source` option, strip out ``level``
  initial directories from absolute paths. This option has no effect without
  :option:`--prefix`.

.. option:: --print-imm-hex

  Use hex format when printing immediate values in disassembly output (default).

.. option:: -S, --source

  When disassembling, display source interleaved with the disassembly. Implies
  :option:`--disassemble`.

.. option:: --show-all-symbols

  Show all symbols during disassembly, even if multiple symbols are defined at
  the same location.

.. option:: --show-lma

  Display the LMA column when dumping ELF section headers. Defaults to off
  unless any section has different VMA and LMAs.

.. option:: --start-address=<address>

  When disassembling, only disassemble from the specified address.

  When printing relocations, only print the relocations patching offsets from at least ``address``.

  When printing symbols, only print symbols with a value of at least ``address``.

.. option:: --stop-address=<address>

  When disassembling, only disassemble up to, but not including the specified address.

  When printing relocations, only print the relocations patching offsets up to ``address``.

  When printing symbols, only print symbols with a value up to ``address``.

.. option:: --symbolize-operands

  When disassembling, symbolize a branch target operand to print a label instead of a real address.

  When printing a PC-relative global symbol reference, print it as an offset from the leading symbol.

  When a bb-address-map section is present (i.e., the object file is built with
  ``-fbasic-block-address-map``), labels are retrieved from that section
  instead. If a pgo-analysis-map is present alongside the bb-address-map, any
  available analyses are printed after the relevant block label. By default,
  any analysis with a special representation (i.e. BlockFrequency,
  BranchProbability, etc) are printed as raw hex values.

  Only supported for AArch64, BPF, PowerPC, and X86.

  Example:
    A non-symbolized branch instruction with a local target and pc-relative memory access like

  .. code-block:: none

      cmp eax, dword ptr [rip + 4112]
      jge 0x20117e <_start+0x25>

  might become

  .. code-block:: none

     <L0>:
       cmp eax, dword ptr <g>
       jge	<L0>

.. option:: --pretty-pgo-analysis-map

  When using :option:`--symbolize-operands` with bb-address-map and
  pgo-analysis-map, print analyses using the same format as their analysis
  passes would. An example of pretty format would be printing block frequencies
  relative to the entry block, the same as BFI.

  Only works when :option:`--symbolize-operands` is enabled.

.. option:: --triple=<string>

  Target triple to disassemble for, see ``--version`` for available targets.

.. option:: -w, --wide

  Ignored for compatibility with GNU objdump.

.. option:: --x86-asm-syntax=<style>

  Deprecated.
  When used with :option:`--disassemble`, choose style of code to emit from
  X86 backend. Supported values are:

   .. option:: att

    AT&T-style assembly

   .. option:: intel

    Intel-style assembly


  The default disassembly style is **att**.

.. option:: -z, --disassemble-zeroes

  Do not skip blocks of zeroes when disassembling.

.. option:: @<FILE>

  Read command-line options and commands from response file `<FILE>`.

MACH-O ONLY OPTIONS AND COMMANDS
--------------------------------

.. option:: --arch=<architecture>

  Specify the architecture to disassemble. see ``--version`` for available
  architectures.

.. option:: --archive-member-offsets

  Print the offset to each archive member for Mach-O archives (requires
  :option:`--archive-headers`).

.. option:: --bind

  Display binding info

.. option:: --data-in-code

  Display the data in code table.

.. option:: --dis-symname=<name>

  Disassemble just the specified symbol's instructions.

.. option:: --chained-fixups

  Print chained fixup information.

.. option:: --dyld-info

  Print bind and rebase information used by dyld to resolve external
  references in a final linked binary.

.. option:: --dylibs-used

  Display the shared libraries used for linked files.

.. option:: --dsym=<string>

  Use .dSYM file for debug info.

.. option:: --dylib-id

  Display the shared library's ID for dylib files.

.. option:: --exports-trie

  Display exported symbols.

.. option:: --function-starts [=<addrs|names|both>]

  Print the function starts table for Mach-O objects. Either ``addrs``
  (default) to print only the addresses of functions, ``names`` to print only
  the names of the functions (when available), or ``both`` to print the
  names beside the addresses.

.. option:: -g

  Print line information from debug info if available.

.. option:: --full-leading-addr

  Print the full leading address when disassembling.

.. option:: --indirect-symbols

  Display the indirect symbol table.

.. option:: --info-plist

  Display the info plist section as strings.

.. option:: --lazy-bind

  Display lazy binding info.

.. option:: --link-opt-hints

  Display the linker optimization hints.

.. option:: -m, --macho

  Use Mach-O specific object file parser. Commands and other options may behave
  differently when used with ``--macho``.

.. option:: --no-leading-headers

  Do not print any leading headers.

.. option:: --no-symbolic-operands

  Do not print symbolic operands when disassembling.

.. option:: --non-verbose

  Display the information for Mach-O objects in non-verbose or numeric form.

.. option:: --objc-meta-data

  Display the Objective-C runtime meta data.

.. option:: --private-header

  Display only the first format specific file header.

.. option:: --rebase

  Display rebasing information.

.. option:: --rpaths

  Display runtime search paths for the binary.

.. option:: --universal-headers

  Display universal headers.

.. option:: --weak-bind

  Display weak binding information.

XCOFF ONLY OPTIONS AND COMMANDS
---------------------------------

.. option:: --symbol-description

  Add symbol description to disassembly output.

.. option:: --traceback-table

  Decode traceback table in disassembly output. Implies :option:`--disassemble`.

BUGS
----

To report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objdump/>.

SEE ALSO
--------

:manpage:`llvm-nm(1)`, :manpage:`llvm-otool(1)`, :manpage:`llvm-readelf(1)`,
:manpage:`llvm-readobj(1)`