773 Commits

Author SHA1 Message Date
John Paul Jepko
cabebddac9
[NFC] Remove unused-but-set global variables (#189315)
Remove four global variables that are set but never read to fix
-Wunused-but-set-global warnings:

- `MFMAChainLength` in AMDGPUIGroupLP.cpp
- `Wide` in llvm-objdump.cpp
- `SaveTemps` in ClangSYCLLinker.cpp
- `DeprecatedDriverCommand` in ClangScanDeps.cpp

Follow up to #178342
2026-03-30 19:29:50 +02:00
Matt Arsenault
9a17aa4878
llvm-objdump: Avoid contraction in error message (#189272) 2026-03-29 18:50:20 +00:00
Ryan Mansfield
24c0384a7e
[llvm-otool] Fix -arch flag for universal binary slice selection (#184810) 2026-03-13 14:01:13 -04:00
Stefan Gränitz
5eaf19a151
Re-reland "[Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC)" (#186074)
Relocate HTTPClient and HTTPServer from the Debuginfod library to
llvm/Support/HTTP so they can be reused by other components.

---------

Relanding with fixes in CMakeLists.txt to account for dependency to new LLVMSupportHTTP in tools.
Relanding with one more fix in libSupportHTTP that adds it as a component in libLLVM.so

---------

Co-authored-by: Alexandre Ganea <aganea@havenstudios.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2026-03-12 15:20:48 +01:00
Stefan Gränitz
90bb98cee9
Revert "Reland "[Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC)"" (#186051)
Reverts llvm/llvm-project#185410

Looks like I have to check polly a well
2026-03-12 08:42:20 +01:00
Stefan Gränitz
4ede3b55cf
Reland "[Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC)" (#185410)
Relocate HTTPClient and HTTPServer from the Debuginfod library to
llvm/Support/HTTP so they can be reused by other components.

---------

Relanding with fixes in CMakeLists.txt to account for dependency to new
LLVMSupportHTTP in tools.

---------

Co-authored-by: Alexandre Ganea <aganea@havenstudios.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2026-03-12 08:14:03 +01:00
Stanislav Mekhanoshin
b5fc8a15e0
[AMDGPU] Recover high VGPRs from S_SETREG_IMM32_B32 in disasm (#185968) 2026-03-11 14:37:14 -07:00
Jan Patrick Lehr
d0a8fccfb2
Revert "[Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC)" (#185372)
Reverts llvm/llvm-project#184572

Breaks many buildbots.
2026-03-09 09:44:27 +01:00
Stefan Gränitz
04dbbd414f
[Support] Move HTTP client/server to new LLVMSupportHTTP lib (NFC) (#184572)
Relocate HTTPClient and HTTPServer from the Debuginfod library to
llvm/Support/HTTP so they can be reused by other components.

---------

Co-authored-by: Alexandre Ganea <aganea@havenstudios.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2026-03-09 07:17:16 +01:00
Fangrui Song
1f53da098f
[llvm-objdump] Default --symbolize-operands for BPF (#184043)
BPF users expect to see basic block labels (e.g. <L0>, <L1>) in
disassembly output

(https://github.com/llvm/llvm-project/pull/95103#issuecomment-3771234810).
Default --symbolize-operands to on for BPF targets when neither
--symbolize-operands nor --no-symbolize-operands is explicitly
specified.

Add --no-symbolize-operands to allow users to opt out.
2026-03-05 08:55:51 +00:00
Ryan Mansfield
655eddad9b
[llvm-otool] Fix error messages to use -p instead of --dis-symname (#181225)
Also fixes llvm-objdump error messages to print --dis-symname instead of
single dash option.
2026-02-13 12:39:37 +00:00
Ruoyu Qiu
da0ad392ff
[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling (#180468)
Reland #174731, resolve cyclic dependency issue.

The use of LLVM_Object in LLVM_Util would cause cyclic dependency.
Fix cyclic dependency by reimplement `getFeatureSetFromEFlag()`.

Original description:

---

This PR updates llvm-objdump to detect the specific AVR architecture
from the ELF header flags when no specific CPU is provided.

Fixes: https://github.com/llvm/llvm-project/issues/146451

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
2026-02-09 21:10:14 +08:00
Henrik G. Olsson
eff21afae0
Revert "[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling" (#180252)
Reverts llvm/llvm-project#174731 due to introducing a cyclic dependency
when building LLVM with modules enabled: LLVM_Utils -> LLVM_Object ->
LLVM_Utils
2026-02-06 19:00:32 +00:00
Ruoyu Qiu
d005cb2953
[llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling (#174731)
This PR updates llvm-objdump to detect the specific AVR architecture
from the ELF header flags when no specific CPU is provided.

Fixes: #146451

---------

Signed-off-by: RuoyuQiu <cabbaken@outlook.com>
Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
Co-authored-by: qiuruoyu <qiuruoyu@hygon.cn>
2026-02-06 08:58:12 +08:00
Sam Elliott
5b4a5cf51f
[RISCV][llvm-objdump] Support --symbolize-operands (#166656)
This adds support for `--symbolize-operands`, so that local references
are turned back into labels by objdump, which makes it easier to tell
what is going on with a linked object.

When using `--symbolize-operands`, branch target addresses are not
printed, only the referenced symbol is printed, and the address is
elided:

```
# Without --symbolize-operands
       0: 04a05263      blez    a0, 0x44 <.text+0x44>
...
      40: fd1ff06f      j       0x10 <.text+0x10>
      44: 00000613      li      a2, 0x0

# With --symbolize-operands
       0: 04a05263      blez    a0,  <L3>
...
      40: fd1ff06f      j        <L0>
<L3>:
      44: 00000613      li      a2, 0x0
```
2026-01-23 09:42:43 -08:00
Ryan Mansfield
dddb1c7282
[llvm-objdump] Fix --disassembler-color with --macho flag (#163815)
The --disassembler-color option was being ignored when using the --macho
flag because DisassembleMachO() never called setUseColor() on the
instruction printer.
2026-01-20 12:17:25 -08:00
Kito Cheng
7d6dc2579e
[RISCV][llvm-readobj,llvm-objdump] Use getRISCVVendorRelocationTypeName for RISCV vendor relocations (#172811)
Use getRISCVVendorRelocationTypeName to resolve RISCV vendor-specific
relocation names (R_RISCV_CUSTOM192-255) when preceded by
R_RISCV_VENDOR.

This improves the output of llvm-readobj and llvm-objdump to show
vendor-specific names like R_RISCV_QC_ABS20_U, R_RISCV_QC_E_BRANCH
(QUALCOMM) and R_RISCV_NDS_BRANCH_10 (ANDES) instead of generic
R_RISCV_CUSTOM* names.

Per RISC-V psABI, R_RISCV_VENDOR must be placed immediately before its
associated vendor-specific relocation, so the vendor symbol is consumed
after one use. Unknown vendors fall back to R_RISCV_CUSTOM*.
2026-01-07 13:46:53 +08:00
Ruoyu Qiu
60418dd8c2
[llvm-objdump] Fix memory leak in mcpuHelp() (#172594)
Reland #165661 with fix for memory leak.

The call to `DummyTarget->createMCSubtargetInfo` within `mcpuHelp()`
returns a pointer that is not subsequently freed, leading to a memory
leak. Use `std::unique_ptr` to ensure the memory is released
automatically.

Original description:

---

Currently --mcpu=help and --mattr=help only produce help out when
disassembling. This patch specialises these cases to always print the
requested help.

If --triple is specified, the help text will be derived from the
specified target. Otherwise, it will be derived from the target of the
first input file.

Fixes: https://github.com/llvm/llvm-project/issues/150567
2025-12-17 10:10:54 +00:00
Qinkun Bao
e04ce74fe2
Revert "[llvm-objdump] Support --mcpu=help/--mattr=help without -d" (#172586)
Reverts llvm/llvm-project#165661

Break
https://lab.llvm.org/buildbot/#/builders/24/builds/15720
https://lab.llvm.org/buildbot/#/builders/55/builds/21517
2025-12-17 03:13:03 +00:00
Ruoyu Qiu
516dd2b70b
[llvm-objdump] Support --mcpu=help/--mattr=help without -d (#165661)
Currently `--mcpu=help` and `--mattr=help` only produce help out when
disassembling. This patch specialises these cases to always print the
requested help.

If `--triple` is specified, the help text will be derived from the
specified target. Otherwise, it will be derived from the target of the
first input file.

Fixes: #150567

---------

Signed-off-by: Ruoyu Qiu <cabbaken@outlook.com>
Co-authored-by: James Henderson <James.Henderson@sony.com>
2025-12-16 14:56:20 +00:00
gulfemsavrun
49516ba0e3
[llvm-objdump] Optimize live element tracking (#158763)
This patch significantly optimizes the LiveElementPrinter
by replacing a slow linear search with efficient hash map
lookups. It refactors the code to use a map-based system
for tracking live element addresses and managing column
assignments, leading to a major performance improvement
for large binaries.
2025-11-26 16:38:47 -08:00
quic-areg
0cdebdaf59
[Hexagon][llvm-objdump] Start a fresh packet at symbol boundaries. (#163466)
Hexagon packets can visually straddle labels when data (e.g. jump
tables) in the text section does not carry end-of-packet bits. In such
cases the next instruction, even at a new symbol, appears to continue
the previous packet.

This patch resets packet state when encountering a new symbol so that
packets at symbol starts are guaranteed to start in their own packet.
2025-10-15 19:11:03 -05:00
Matt Arsenault
67823469bd
MC: Add Triple overloads for more MC constructors (#157321)
Avoids more Triple->string->Triple round trip. This
is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-09-08 03:41:22 +00:00
Sam Elliott
4e11f89904
[RISCV] Basic Objdump Mapping Symbol Support (#151452)
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 11:28:07 -07:00
Chris B
2fe96439fb
[DirectX] Add ObjectFile boilerplate for objdump (#151434)
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 10:57:25 -05:00
Kazu Hirata
35dd88918f
[llvm] Use llvm::iterator_range::empty (NFC) (#151905) 2025-08-04 07:40:46 -07:00
gulfemsavrun
e94bc16b8e
[llvm-objdump] Add inlined function display support (#142246)
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-21 12:51:27 +03:00
quic-areg
ac7ceb3dab
[Hexagon][llvm-objdump] Improve disassembly of Hexagon bundles (#145807)
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-18 10:27:59 -05:00
Alexis Engelke
36819eaed1
[llvm-objdump] Support --symbolize-operand on AArch64
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-25 17:09:25 +02:00
Alexey Karyakin
c87edaf99b
[Hexagon][llvm-objdump] Fix crash at a truncated instruction (#142082)
Fixes #141740.

Co-authored-by: Alexey Karyakin <quic-akaryaki@quicinc.com>
Co-authored-by: Sudharsan Veeravalli <quic_svs@quicinc.com>
2025-05-30 12:10:11 -05:00
Kazu Hirata
c41a4a8b54
[llvm-objdump] Remove unused includes (NFC) (#141390)
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-25 08:22:54 -07:00
David Salinas
51a03ed272
Extend llvm objdump fatbin (#140286)
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-23 11:55:16 -04:00
Fangrui Song
95e4db8fa7
[llvm-objdump] --adjust-vma: Call getInstruction with adjusted address
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-20 08:54:53 -07:00
Kazu Hirata
9c3ab1cfc8 Revert "Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)"
This reverts commit 910220b84fa18ce2cbb2e21dd53b9f3d0ae582a7.

Multiple buildbot failures have been reported:
https://github.com/llvm/llvm-project/pull/140128
2025-05-16 07:23:21 -07:00
David Salinas
910220b84f
Reapply: [llvm-objdump] Add support for HIP offload bundles (#140128)
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-16 09:39:15 -04:00
Prabhu Rajasekaran
15b20a13e6
[NFC][llvm-objdump] Add ostream param to control console prints (#139931) 2025-05-15 09:30:15 -07:00
Sergei Barannikov
e79c2bd733
[llvm-objdump] Print symbolized labels with increasing index (#139415)
To make it easier to navigate the disassembly listing.
2025-05-11 03:37:08 +03:00
Fangrui Song
fa248750c0 llvm-objdump --adjust-vma: Don't adjust VMA in inline reloc addresses
--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-10 14:39:53 -07:00
Kazu Hirata
2299bada9f Revert "[llvm-objdump] Add support for HIP offload bundles (#114834)"
This reverts commit 06d6623bc304d5fc2fe11b80b62b4c5d10f9eaa1.

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/145/builds/6871/steps/5/logs/stdio
2025-05-08 17:20:18 -07:00
David Salinas
06d6623bc3
[llvm-objdump] Add support for HIP offload bundles (#114834)
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-08 17:32:10 -04:00
Kazu Hirata
ab58bcfac4
[tools] Use llvm::append_range (NFC) (#135721) 2025-04-14 22:21:40 -07:00
Kazu Hirata
0ae9c65d4a
[tools] Use *Set::insert_range (NFC) (#133384)
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-28 07:53:09 -07:00
Vladislav Dzhidzhoev
bcad050106
[llvm-objdump][ARM] Find ELF file PLT entries for arm, thumb (#130764)
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-26 20:18:23 +01:00
Kazu Hirata
599005686a
[llvm] Use *Set::insert_range (NFC) (#132325)
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-20 22:24:06 -07:00
Vladislav Dzhidzhoev
84e44ae6b7
[llvm-objdump] Pass MCSubtargetInfo to findPltEntries (NFC) (#131773)
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-18 14:00:34 +01:00
Fangrui Song
7c26356703
[llvm-objdump] Rework .gnu.version_d dumping
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-28 09:38:48 -08:00
Chandler Carruth
cd5694ecea
[StrTable] Switch the option parser to llvm::StringTable (#123308)
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-22 23:19:47 -08:00
Cabbaken
630b7f3673
[llvm-objdump] Remove some unneeded headers. (#120541)
Co-authored-by: qiuruoyu <qiuruoyu@xiaomi.com>
2024-12-23 10:16:06 +00:00
Chandler Carruth
dd647e3e60
Rework the Option library to reduce dynamic relocations (#119198)
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-11 15:44:44 -08:00
hstk30-hw
2f5bfb41e2
[llvm-objdump] Default to --mattr=+all for AArch64be and AArch64_32 (#118311)
GNU objdump disassembles all unknown instructions by default. 
Complement for [D128030](https://reviews.llvm.org/D128030)。
2024-12-03 11:18:17 +08:00