[llvm] [llvm-objdump] Pass MCSubtargetInfo to findPltEntries (NFC) (PR #131773)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 18 03:09:56 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Vladislav Dzhidzhoev (dzhidzhoev)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/131773.diff
8 Files Affected:
- (modified) llvm/include/llvm/MC/MCInstrAnalysis.h (+1-1)
- (modified) llvm/include/llvm/Object/ELFObjectFile.h (+2-1)
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+3-2)
- (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp (+1-1)
- (modified) llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp (+1-1)
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp (+3-2)
- (modified) llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp (+1-1)
- (modified) llvm/tools/llvm-objdump/llvm-objdump.cpp (+3-3)
``````````diff
diff --git a/llvm/include/llvm/MC/MCInstrAnalysis.h b/llvm/include/llvm/MC/MCInstrAnalysis.h
index b571791c518da..7ad4c5f49623f 100644
--- a/llvm/include/llvm/MC/MCInstrAnalysis.h
+++ b/llvm/include/llvm/MC/MCInstrAnalysis.h
@@ -195,7 +195,7 @@ class MCInstrAnalysis {
/// Returns (PLT virtual address, GOT virtual address) pairs for PLT entries.
virtual std::vector<std::pair<uint64_t, uint64_t>>
findPltEntries(uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents,
- const Triple &TargetTriple) const {
+ const MCSubtargetInfo &STI) const {
return {};
}
};
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index bafc92cafe539..35f1fc3d5814b 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ELFTypes.h"
@@ -107,7 +108,7 @@ class ELFObjectFileBase : public ObjectFile {
virtual uint8_t getEIdentABIVersion() const = 0;
- std::vector<ELFPltEntry> getPltEntries() const;
+ std::vector<ELFPltEntry> getPltEntries(const MCSubtargetInfo &STI) const;
/// Returns a vector containing a symbol version for each dynamic symbol.
/// Returns an empty vector if version sections do not exist.
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index d0897c62b3e8e..21cb77e399a97 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -778,7 +778,8 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
TheTriple.setArchName(Triple);
}
-std::vector<ELFPltEntry> ELFObjectFileBase::getPltEntries() const {
+std::vector<ELFPltEntry>
+ELFObjectFileBase::getPltEntries(const MCSubtargetInfo &STI) const {
std::string Err;
const auto Triple = makeTriple();
const auto *T = TargetRegistry::lookupTarget(Triple, Err);
@@ -836,7 +837,7 @@ std::vector<ELFPltEntry> ELFObjectFileBase::getPltEntries() const {
llvm::append_range(
PltEntries,
MIA->findPltEntries(Section.getAddress(),
- arrayRefFromStringRef(*PltContents), Triple));
+ arrayRefFromStringRef(*PltContents), STI));
}
}
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
index 7f781811a5058..dd3ecb41494e0 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
@@ -465,7 +465,7 @@ class AArch64MCInstrAnalysis : public MCInstrAnalysis {
std::vector<std::pair<uint64_t, uint64_t>>
findPltEntries(uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents,
- const Triple &TargetTriple) const override {
+ const MCSubtargetInfo &STI) const override {
// Do a lightweight parsing of PLT entries.
std::vector<std::pair<uint64_t, uint64_t>> Result;
for (uint64_t Byte = 0, End = PltContents.size(); Byte + 7 < End;
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
index 80e5c10691393..4edbe4875c98b 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -749,7 +749,7 @@ class HexagonMCInstrAnalysis : public MCInstrAnalysis {
std::vector<std::pair<uint64_t, uint64_t>>
findPltEntries(uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents,
- const Triple &TargetTriple) const override {
+ const MCSubtargetInfo &STI) const override {
// Do a lightweight parsing of PLT entries.
std::vector<std::pair<uint64_t, uint64_t>> Result;
for (uint64_t Byte = 0x0, End = PltContents.size(); Byte < End; Byte += 4) {
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 1c4d68d5448d6..ad94e306f339e 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -514,7 +514,7 @@ class X86MCInstrAnalysis : public MCInstrAnalysis {
APInt &Mask) const override;
std::vector<std::pair<uint64_t, uint64_t>>
findPltEntries(uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents,
- const Triple &TargetTriple) const override;
+ const MCSubtargetInfo &STI) const override;
bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
uint64_t &Target) const override;
@@ -630,7 +630,8 @@ findX86_64PltEntries(uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents) {
std::vector<std::pair<uint64_t, uint64_t>>
X86MCInstrAnalysis::findPltEntries(uint64_t PltSectionVA,
ArrayRef<uint8_t> PltContents,
- const Triple &TargetTriple) const {
+ const MCSubtargetInfo &STI) const {
+ const auto TargetTriple = STI.getTargetTriple();
switch (TargetTriple.getArch()) {
case Triple::x86:
return findX86PltEntries(PltSectionVA, PltContents);
diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
index 64ebe48fe8f42..e6f36735e84b9 100644
--- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
+++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
@@ -574,7 +574,7 @@ Error FileAnalysis::parseSymbolTable() {
}
}
if (auto *ElfObject = dyn_cast<object::ELFObjectFileBase>(Object)) {
- for (const auto &Plt : ElfObject->getPltEntries()) {
+ for (const auto &Plt : ElfObject->getPltEntries(*SubtargetInfo)) {
if (!Plt.Symbol)
continue;
object::SymbolRef Sym(*Plt.Symbol, Object);
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 115f04a4df778..beed2ddcd981d 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1233,7 +1233,7 @@ addMissingWasmCodeSymbols(const WasmObjectFile &Obj,
}
}
-static void addPltEntries(const ObjectFile &Obj,
+static void addPltEntries(const MCSubtargetInfo &STI, const ObjectFile &Obj,
std::map<SectionRef, SectionSymbolsTy> &AllSymbols,
StringSaver &Saver) {
auto *ElfObj = dyn_cast<ELFObjectFileBase>(&Obj);
@@ -1248,7 +1248,7 @@ static void addPltEntries(const ObjectFile &Obj,
}
Sections[*SecNameOrErr] = Section;
}
- for (auto Plt : ElfObj->getPltEntries()) {
+ for (auto Plt : ElfObj->getPltEntries(STI)) {
if (Plt.Symbol) {
SymbolRef Symbol(*Plt.Symbol, ElfObj);
uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
@@ -1772,7 +1772,7 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
BumpPtrAllocator A;
StringSaver Saver(A);
- addPltEntries(Obj, AllSymbols, Saver);
+ addPltEntries(*DT->SubtargetInfo, Obj, AllSymbols, Saver);
// Create a mapping from virtual address to section. An empty section can
// cause more than one section at the same address. Sort such sections to be
``````````
</details>
https://github.com/llvm/llvm-project/pull/131773
More information about the llvm-commits
mailing list