Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCInstrAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
};
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/Object/ELFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Object/ELFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -836,7 +837,7 @@ std::vector<ELFPltEntry> ELFObjectFileBase::getPltEntries() const {
llvm::append_range(
PltEntries,
MIA->findPltEntries(Section.getAddress(),
arrayRefFromStringRef(*PltContents), Triple));
arrayRefFromStringRef(*PltContents), STI));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Loading