aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump
AgeCommit message (Collapse)AuthorFilesLines
2025-09-09MC: Use Triple form of lookupTarget in more places (#157591)Matt Arsenault1-2/+2
2025-09-08MC: Add Triple overloads for more MC constructors (#157321)Matt Arsenault2-40/+45
Avoids more Triple->string->Triple round trip. This is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-08-15[DirectX][objdump] Add support for printing signatures (#153320)Chris B1-2/+138
This adds support for printing the signature sections as part of the `-p` flag for printing private headers. The formatting aims to roughly match the formatting used by DXC's `/dumpbin` flag. The original version's printed output left some trailing whitespace on lines, which caused the tests to fail with the strict whitespace matching. Re-lands #152531. Resolves #152380.
2025-08-12Revert "[DirectX][objdump] Add support for printing signatures" (#153313)Chris B1-127/+2
Reverts llvm/llvm-project#152531
2025-08-12[DirectX][objdump] Add support for printing signatures (#152531)Chris B1-2/+127
This adds support for printing the signature sections as part of the `-p` flag for printing private headers. The formatting aims to roughly match the formatting used by DXC's `/dumpbin` flag. Resolves #152380.
2025-08-11[llvm-objdump] Remove unnecessary casts (NFC) (#153128)Kazu Hirata1-3/+3
Ptr is already of const char *.
2025-08-07[RISCV] Basic Objdump Mapping Symbol Support (#151452)Sam Elliott1-1/+7
This implements very basic support for RISC-V mapping symbols in llvm-objdump, sharing the implementation with how Arm/AArch64/CSKY implement this feature. This only supports the `$x` (instruction) and `$d` (data) mapping symbols for RISC-V, and not the version of `$x` which includes an architecture string suffix.
2025-08-07[llvm-objdump] Remove unnecessary casts (NFC) (#152443)Kazu Hirata1-8/+8
data() alaready returns const char *.
2025-08-04[DirectX] Add ObjectFile boilerplate for objdump (#151434)Chris B4-0/+37
This change adds boilerplate code to implement the object::ObjectFile interface for the DXContainer object file and an empty implementation of the objdump Dumper object. Adding an ObjectFile implementation for DXContainer is a bit odd because the DXContainer format doesn't have a symbol table, so there isn't a reasonable implementation for the SymbolicFile interfaces. That said, it does have sections, and it will be useful for objdump to be able to inspect some of the structured data stored in some of the special named sections. At this point in the implementation it can't do much other than dump the part names, offsets, and sizes. Dumping detailed structured section contents to be extended in subsequent PRs. Fixes #151433
2025-08-04[llvm] Use llvm::iterator_range::empty (NFC) (#151905)Kazu Hirata1-1/+1
2025-08-02[llvm-objdump] Remove an unnecessary cast (NFC) (#151799)Kazu Hirata1-1/+1
Size is already of uint32_t.
2025-07-21[llvm-objdump] Add inlined function display support (#142246)gulfemsavrun5-155/+352
This patch adds the support for displaying inlined functions into llvm-objdump. 1) It extends the source variable display support for inlined functions both for ascii and unicode formats. 2) It also introduces a new format called limits-only that only prints a line for the start and end of an inlined function without line-drawing characters.
2025-07-18[Hexagon][llvm-objdump] Improve disassembly of Hexagon bundles (#145807)quic-areg1-73/+107
Hexagon instructions are VLIW "bundles" of up to four instruction words encoded as a single MCInst with operands for each sub-instruction. Previously, the disassembler's getInstruction() returned the full bundle, which made it difficult to work with llvm-objdump. For example, since all instructions are bundles, and bundles do not branch, branch targets could not be printed. This patch modifies the Hexagon disassembler to return individual sub-instructions instead of entire bundles, enabling correct printing of branch targets and relocations. It also introduces `MCDisassembler::getInstructionBundle` for cases where the full bundle is still needed. By default, llvm-objdump separates instructions with newlines. However, this does not work well for Hexagon syntax: { inst1 inst2 inst3 inst4 <branch> } :endloop0 Instructions may be followed by a closing brace, a closing brace with `:endloop`, or a newline. Branches must appear within the braces. To address this, `PrettyPrinter::getInstructionSeparator()` is added and overridden for Hexagon.
2025-07-16[elf] Add support for {SHT,PT}_GNU_SFRAME constants (#148803)Pavel Labath1-0/+3
Reference: https://sourceware.org/git/?p=gnu-gabi.git;a=blob;f=program-loading-and-dynamic-linking.txt;h=3357d865720285df2d29c4e8f92de49ddf1beb40;hb=refs/heads/master
2025-06-27Reapply "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#… ↵Sterling-Augustine2-2/+4
(#145959) (#146112) Reapply "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#… (#145959) This reapplies cbf781f0bdf2f680abbe784faedeefd6f84c246e, with fixes for the shared-library build and the unconventional sanitizer-runtime build. Original Description: This is the culmination of a series of changes described in [1]. Although somewhat large by line count, it is almost entirely mechanical, creating a new library in DebugInfo/DWARF/LowLevel. This new library has very minimal dependencies, allowing it to be used from more places than the normal DebugInfo/DWARF library--in particular from MC. 1. https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665/2
2025-06-26Revert "[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#… ↵Sterling-Augustine2-4/+2
(#145959) …145081)" This reverts commit cbf781f0bdf2f680abbe784faedeefd6f84c246e. Breaks a couple of buildbots.
2025-06-26[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#145081)Sterling-Augustine2-2/+4
This is the culmination of a series of changes described in [1]. Although somewhat large by line count, it is almost entirely mechanical, creating a new library in DebugInfo/DWARF/LowLevel. This new library has very minimal dependencies, allowing it to be used from more places than the normal DebugInfo/DWARF library--in particular from MC. I am happy to put it in another location, or to structure it differently if that makes sense. Some have suggested in BinaryFormat, but it is not a great fit there. But if that makes more sense to the reviewers, I can do that. Another possibility would be to use pass-through headers to allow clients who don't care to depend only on DebugInfo/DWARF. This would be a much less invasive change, and perhaps easier for clients. But also a system that hides details. Either way, I'm open. 1. https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665/2
2025-06-25[llvm-objdump] Support --symbolize-operand on AArch64Alexis Engelke1-1/+2
Similar to the existing implementations for X86 and PPC, support symbolizing branch targets for AArch64. Do not omit the address for ADRP as the target is typically not at an intended location. Pull Request: https://github.com/llvm/llvm-project/pull/145009
2025-06-09[NFC] Separate high-level-dependent portions of DWARFExpression (revised) ↵Sterling-Augustine1-1/+1
(#143170) (Revised version of a previous, unreviewed, PR.) Move all expression verification into its only client: DWARFVerifier. Move all printing code (which was a mix of static and member functions) into a separate class. This is one in a series of refactoring PRs to separate dwarf functionality into lower-level pieces usable without object files and sections at build time. The code is already written this way via various "if (section == nullptr)" and similar conditionals. So the functionality itself is needed and exists, but only as a runtime feature. The goal of these refactors is to remove the build-time dependencies, which will allow the existing functionality to be used from lower-level parts of the compiler. Particularly from lib/MC/.... More information at: https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665
2025-05-30[Hexagon][llvm-objdump] Fix crash at a truncated instruction (#142082)Alexey Karyakin1-4/+8
Fixes #141740. Co-authored-by: Alexey Karyakin <quic-akaryaki@quicinc.com> Co-authored-by: Sudharsan Veeravalli <quic_svs@quicinc.com>
2025-05-25[llvm-objdump] Remove unused includes (NFC) (#141390)Kazu Hirata3-8/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-23Extend llvm objdump fatbin (#140286)David Salinas3-3/+50
Utilize the new extensions to the LLVM Offloading API to extend to llvm-objdump to handle dumping fatbin offload bundles generated by HIP. This extension to llvm-objdump adds the option --offload-fatbin. Specifying this option will take the input object/executable and extract all offload fatbin bundle entries into distinct code object files with names reflecting the source file name combined with the Bundle Entry ID. Users can also use the --arch-name option to filter offload fatbin bundle entries by their target triple. --------- Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-20[llvm-objdump] --adjust-vma: Call getInstruction with adjusted addressFangrui Song1-1/+1
llvm-objdump currently calls MCDisassembler::getInstruction with unadjusted address and MCInstPrinter::printInst with adjusted address. The decoded branch targets will be adjusted as expected for most targets (as the getInstruction address is insignificant) but not for SystemZ (where the getInstruction address is displayed). Specify an adjust address to fix SystemZInstPrinter output. The added test utilizes llvm/utils/update_test_body.py to make updates easier and additionally checks that we don't adjust SHN_ABS symbol addresses. Pull Request: https://github.com/llvm/llvm-project/pull/140471
2025-05-16Revert "Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)"Kazu Hirata3-52/+3
This reverts commit 910220b84fa18ce2cbb2e21dd53b9f3d0ae582a7. Multiple buildbot failures have been reported: https://github.com/llvm/llvm-project/pull/140128
2025-05-16Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)David Salinas3-3/+52
Utilize the new extensions to the LLVM Offloading API to extend to llvm-objdump to handle dumping fatbin offload bundles generated by HIP. This extension to llvm-objdump adds the option --offload-fatbin. Specifying this option will take the input object/executable and extract all offload fatbin bundle entries into distinct code object files with names reflecting the source file name combined with the Bundle Entry ID. Users can also use the --arch-name option to filter offload fatbin bundle entries by their target triple. --------- Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-15[NFC][llvm-objdump] Add ostream param to control console prints (#139931)Prabhu Rajasekaran1-30/+29
2025-05-11[llvm-objdump] Print symbolized labels with increasing index (#139415)Sergei Barannikov1-4/+7
To make it easier to navigate the disassembly listing.
2025-05-10llvm-objdump --adjust-vma: Don't adjust VMA in inline reloc addressesFangrui Song1-9/+1
--adjust-vma adjusts the current section address. The address printed for inline relocs is relative to the current section address instead of the section that the referenced symbol resides in. Fix https://github.com/llvm/llvm-project/issues/75444
2025-05-08Revert "[llvm-objdump] Add support for HIP offload bundles (#114834)"Kazu Hirata3-52/+3
This reverts commit 06d6623bc304d5fc2fe11b80b62b4c5d10f9eaa1. Buildbot failure: https://lab.llvm.org/buildbot/#/builders/145/builds/6871/steps/5/logs/stdio
2025-05-08[llvm-objdump] Add support for HIP offload bundles (#114834)David Salinas3-3/+52
Utilize the new extensions to the LLVM Offloading API to extend to llvm-objdump to handle dumping fatbin offload bundles generated by HIP. This extension to llvm-objdump adds the option --offload-fatbin. Specifying this option will take the input object/executable and extract all offload fatbin bundle entries into distinct code object files with names reflecting the source file name combined with the Bundle Entry ID. Users can also use the --arch-name option to filter offload fatbin bundle entries by their target triple. --------- Co-authored-by: dsalinas <dsalinas@MKM-L1-DSALINAS.amd.com>
2025-05-03[tools] Remove unused local variables (NFC) (#138384)Kazu Hirata1-1/+0
2025-04-14[tools] Use llvm::append_range (NFC) (#135721)Kazu Hirata1-2/+1
2025-03-28[tools] Use *Set::insert_range (NFC) (#133384)Kazu Hirata1-2/+1
We can use *Set::insert_range to replace "for" loop-based insertions. In some cases, we can further fold insert_range into the set declaration.
2025-03-26[llvm-objdump][ARM] Find ELF file PLT entries for arm, thumb (#130764)Vladislav Dzhidzhoev1-8/+38
This implements arm, armeb, thumb, thumbeb PLT entries parsing support in ELF for llvm-objdump. Implementation is similar to AArch64MCInstrAnalysis::findPltEntries. PLT entry signatures are based on LLD code for PLT generation (ARM::writePlt). llvm-objdump tests are produced from lld/test/ELF/arm-plt-reloc.s, lld/test/ELF/armv8-thumb-plt-reloc.s.
2025-03-20[llvm] Use *Set::insert_range (NFC) (#132325)Kazu Hirata1-1/+1
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src); This patch does not touch custom begin like succ_begin for now.
2025-03-18[llvm-objdump] Delete unused variables after #128434Fangrui Song1-6/+0
2025-03-18[llvm-objdump] Pass MCSubtargetInfo to findPltEntries (NFC) (#131773)Vladislav Dzhidzhoev1-3/+3
It allows access to subtarget features, collected in llvm-objdump.cpp, from findPltEntries, which will be used in https://github.com/llvm/llvm-project/pull/130764.
2025-03-17[NFC][DebugInfo] Wrap DILineInfo return type with std::optional to handle ↵Zequan Wu1-1/+2
missing debug info. (#129792) Currently, `DIContext::getLineInfoForAddress` and `DIContext::getLineInfoForDataAddress` returns empty DILineInfo when the debug info is missing for the given address. This is not differentiable with the case when debug info is found for the given address but the debug info is default value (filename:linenum is <invalid>:0). This change wraps the return types of `DIContext::getLineInfoForAddress` and `DIContext::getLineInfoForDataAddress` with `std::optional`.
2025-03-09[llvm-objdump][ELF]Fix crash when reading strings from .dynstr (#125679)Ruoyu Qiu1-2/+19
This change introduces a check for the strtab offset to prevent llvm-objdump from crashing when processing malformed ELF files. It provide a minimal reproduce test for https://github.com/llvm/llvm-project/issues/86612#issuecomment-2035694455. Additionally, it modifies how llvm-objdump handles and outputs malformed ELF files with invalid string offsets.(More info: https://discourse.llvm.org/t/should-llvm-objdump-objdump-display-actual-corrupted-values-in-malformed-elf-files/84391) Fixes: #86612 Co-authored-by: James Henderson <James.Henderson@sony.com>
2025-02-28[llvm-objdump] Rework .gnu.version_d dumpingFangrui Song3-36/+21
and fix crash when vd_aux is invalid (#86611). vd_version, vd_flags, vd_ndx, and vd_cnt in Elf{32,64}_Verdef are 16-bit. Change VerDef to use uint16_t instead. vda_name specifies a NUL-terminated string. Update getVersionDefinitions to remove some `.c_str()`. Pull Request: https://github.com/llvm/llvm-project/pull/128434
2025-02-24[llvm-objdump]Correct .dynstr finding of getDynamicStrTab() (#127975)Ruoyu Qiu1-2/+2
The dynamic string table used by the dynamic section is referenced by the sh_link field of that section, so we should use that directly, rather than going via the dynamic symbol table. More info: https://github.com/llvm/llvm-project/pull/125679#discussion_r1961333454 Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
2025-01-22[StrTable] Switch the option parser to `llvm::StringTable` (#123308)Chandler Carruth1-1/+2
Now that we have a dedicated abstraction for string tables, switch the option parser library's string table over to it rather than using a raw `const char*`. Also try to use the `StringTable::Offset` type rather than a raw `unsigned` where we can to avoid accidental increments or other issues. This is based on review feedback for the initial switch of options to a string table. Happy to tweak or adjust if desired here.
2025-01-20[llvm-objdump] Print out xcoff load section of xcoff object file with option ↵zhijian lin1-0/+41
private-headers (#121226) [llvm-objdump] Print out xcoff load section of xcoff object file with option private-headers
2025-01-13[llvm] Win x64 Unwind V2 2/n: Support dumping UOP_Epilog (#110338)Daniel Paoliello1-3/+21
Adds support to objdump and readobj for reading the `UOP_Epilog` entries of Windows x64 unwind v2. `UOP_Epilog` has a weird format: The first `UOP_Epilog` in the unwind data is the "header": * The least-significant bit of `OpInfo` is the "At End" flag, which signifies that there is an epilog at the very end of the associated function. * `CodeOffset` is the length each epilog described by the current unwind information (all epilogs have the same length). Any subsequent `UOP_Epilog` represents another epilog for the current function, where `OpInfo` and `CodeOffset` are combined to a 12-bit value which is the offset of the beginning of the epilog from the end of the current function. If the offset is 0, then this entry is actually padding and can be ignored.
2025-01-13[llvm-objdump] Remove leading whitespace for PT_GNU_PROPERTY. (#121591)Ryan Mansfield1-1/+1
This fixes the misaligned display of addresses for this p_type. Previous: ``` STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**64 filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw- PROPERTY off 0x0000000000000358 vaddr 0x0000000000000358 paddr 0x0000000000000358 align 2**3 filesz 0x0000000000000020 memsz 0x0000000000000020 flags r-- NOTE off 0x0000000000000334 vaddr 0x0000000000000334 paddr 0x0000000000000334 align 2**2 filesz 0x0000000000000020 memsz 0x0000000000000020 flags r-- ``` After: ``` STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**64 filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw- PROPERTY off 0x0000000000000358 vaddr 0x0000000000000358 paddr 0x0000000000000358 align 2**3 filesz 0x0000000000000020 memsz 0x0000000000000020 flags r-- NOTE off 0x0000000000000334 vaddr 0x0000000000000334 paddr 0x0000000000000334 align 2**2 filesz 0x0000000000000020 memsz 0x0000000000000020 flags r-- ```
2024-12-23[llvm-objdump] Remove some unneeded headers. (#120541)Cabbaken5-12/+0
Co-authored-by: qiuruoyu <qiuruoyu@xiaomi.com>
2024-12-11Rework the `Option` library to reduce dynamic relocations (#119198)Chandler Carruth1-17/+22
Apologies for the large change, I looked for ways to break this up and all of the ones I saw added real complexity. This change focuses on the option's prefixed names and the array of prefixes. These are present in every option and the dominant source of dynamic relocations for PIE or PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which has a huge number of options. This PR addresses this by building a string table and a prefixes table that can be referenced with indices rather than pointers that require dynamic relocations. This removes almost 7k dynmaic relocations from the `clang` binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For busy-boxing use cases where many different option tables are linked into the same binary, the savings add up a bit more. The string table is a straightforward mechanism, but the prefixes required some subtlety. They are encoded in a Pascal-string fashion with a size followed by a sequence of offsets. This works relatively well for the small realistic prefixes arrays in use. Lots of code has to change in order to land this though: both all the option library code has to be updated to use the string table and prefixes table, and all the users of the options library have to be updated to correctly instantiate the objects. Some follow-up patches in the works to provide an abstraction for this style of code, and to start using the same technique for some of the other strings here now that the infrastructure is in place.
2024-12-03[llvm-objdump] Default to --mattr=+all for AArch64be and AArch64_32 (#118311)hstk30-hw1-1/+1
GNU objdump disassembles all unknown instructions by default. Complement for [D128030](https://reviews.llvm.org/D128030)。
2024-11-07[llvm-objdump] Implement decoding auxiliary header for xcoff with ↵zhijian lin1-4/+200
llvm-objdump --private-headers (#105682) Implement decoding auxiliary header of XCOFF object file with llvm-objdump --private-headers
2024-10-28[llvm-objdump] Handle -M for --machoFangrui Song3-1/+6
--macho -d uses the `parseInputMachO` code path, which does not handle -M. Add -M handling for --macho as well. Close #61019 Pull Request: https://github.com/llvm/llvm-project/pull/113795