aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump
AgeCommit message (Collapse)AuthorFilesLines
7 days[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.
9 days[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.
12 days[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
2024-09-25[llvm-objdump] Print ... even if a data mapping symbol is activeFangrui Song1-17/+18
Swap `!DisassembleZeroes` and `if (DumpARMELFData)` conditions so that in the false DisassembleZeroes case (default), `...` will be printed for long consecutive zeroes, even when a data mapping symbol is active. This is especially useful for certain lld tests that insert a huge padding within a code section. Without `...` the output will be huge. Pull Request: https://github.com/llvm/llvm-project/pull/109553
2024-09-25[SystemZ][z/OS] Open text files in text mode (#109972)Abhina Sree1-1/+2
This patch continues the work that was started here https://reviews.llvm.org/D99426 to correctly open text files in text mode.
2024-09-13[MC] Use std::optional<MCRegisters> for values returned by ↵Craig Topper1-1/+1
MCRegisterInfo::getLLVMRegNum. NFC I missed a few places when I changed the function return type in f2b71491d11355c0df0c92ef7cce7d610c894660.
2024-08-20[AArch64][MachO] Add ptrauth ABI version to arm64e cpusubtype. (#104650)Ahmed Bougacha1-3/+21
In a mach_header, the cpusubtype is a 32-bit field, but it's split in 2 subfields: - the low 24 bits containing the cpu subtype proper, (e.g., CPU_SUBTYPE_ARM64E 2) - the high 8 bits containing a capability field used for additional feature flags. Notably, it's only the subtype subfield that participates in fat file slice discrimination: the caps are ignored. arm64e uses the caps subfield to encode a ptrauth ABI version: - 0x80 (CPU_SUBTYPE_PTRAUTH_ABI) denotes a versioned binary - 0x40 denotes a kernel-ABI binary - 0x00-0x0F holds the ptrauth ABI version This teaches the basic obj tools to decode that (or ignore it when unneeded). It also teaches the MachO writer to default to emitting versioned binaries, but with a version of 0 (and without the kernel ABI flag). Modern arm64e requires versioned binaries: a binary with 0x00 caps in cpusubtype is now rejected by the linker and everything after. We can live without the sophistication of specifying the version and kernel ABI for now. Co-authored-by: Francis Visoiu Mistrih <francisvm@apple.com>
2024-08-15[llvm-objdump] Fix a warningKazu Hirata1-0/+1
This patch fixes: llvm/tools/llvm-objdump/XCOFFDump.cpp:85:12: error: unused variable 'BytesFormatted' [-Werror,-Wunused-variable]
2024-08-15llvm-objdump: ensure a MachO symbol isn't STAB before looking up secion (#86667)Tim Northover1-10/+10
The section field has been repurposed for some STAB symbol types, and if we blindly look it up we'll produce an error and terminate. Logic already existed Existing stabs test had a section that was in range. Unfortunately I don't know of an easy way to produce stabs entries in LLVM (I thought they died in the 90s until this came up) so I just binary-edited it to cause a failure on existing llvm-objdump.
2024-08-15[llvm-objdump] Print out xcoff file header for xcoff object file with ↵zhijian lin1-2/+80
option private-headers (#96350) Print out the XCOFF file header and load section header for the XCOFF object file using llvm-objdump with the --private-headers option.
2024-07-31[llvm-objdump][BPF] --symbolize-operands: infer local labels for BPF (#100550)eddyz871-2/+4
Enable local labels computation for BPF disassembly when `--symbolize-operands` option is specified. This relies on `MCInstrAnalysis::evaluateBranch()` method, which is already defined in `BPFMCInstrAnalysis::evaluateBranch`. After this change the assembly code below: if r1 > 42 goto +1 r1 -= 10 ... Would be printed as: if r1 > 42 goto +1 <L0> r1 -= 10 <L0>: ... (when `--symbolize-operands` option is set). See https://reviews.llvm.org/D84191 for the main part of the `--symbolize-operands` implementation logic.
2024-07-08[llvm-objdump] -r: support CRELFangrui Song2-1/+15
Extract the llvm-readelf decoder to `decodeCrel` (#91280) and reuse it for llvm-objdump. Because the section representation of LLVMObject (`SectionRef`) is 64-bit, insufficient to hold all decoder states, `section_rel_begin` is modified to decode CREL eagerly and hold the decoded relocations inside ELFObjectFile<ELFT>. The test is adapted from llvm/test/tools/llvm-readobj/ELF/crel.test. Pull Request: https://github.com/llvm/llvm-project/pull/97382
2024-07-07[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#97914)Kazu Hirata1-1/+1
2024-06-21[llvm-objdump] enable file-headers option of llvm-objdump for XCOFF object ↵zhijian lin1-1/+1
files (#96104) the patch enable file-headers option of llvm-objdump for XCOFF object files