summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputFiles.cpp15
-rw-r--r--lld/ELF/InputFiles.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 4f7fc742af8..cc5ea7aee03 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -27,24 +27,23 @@ template <class ELFT> static uint16_t getEMachine(const ELFFileBase &B) {
return cast<ObjectFile<ELFT>>(B).getEMachine();
}
-static uint16_t getEMachine(const ELFFileBase &B) {
- ELFKind K = B.getELFKind();
- switch (K) {
+uint16_t ELFFileBase::getEMachine() const {
+ switch (EKind) {
case ELF32BEKind:
- return getEMachine<ELF32BE>(B);
+ return ::getEMachine<ELF32BE>(*this);
case ELF32LEKind:
- return getEMachine<ELF32LE>(B);
+ return ::getEMachine<ELF32LE>(*this);
case ELF64BEKind:
- return getEMachine<ELF64BE>(B);
+ return ::getEMachine<ELF64BE>(*this);
case ELF64LEKind:
- return getEMachine<ELF64LE>(B);
+ return ::getEMachine<ELF64LE>(*this);
}
llvm_unreachable("Invalid kind");
}
bool ELFFileBase::isCompatibleWith(const ELFFileBase &Other) const {
return getELFKind() == Other.getELFKind() &&
- getEMachine(*this) == getEMachine(Other);
+ getEMachine() == Other.getEMachine();
}
template <class ELFT> void ELFData<ELFT>::openELF(MemoryBufferRef MB) {
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index d8d07698e10..52f4d1751d2 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -62,6 +62,8 @@ public:
bool isCompatibleWith(const ELFFileBase &Other) const;
ELFKind getELFKind() const { return EKind; }
+ uint16_t getEMachine() const;
+
protected:
const ELFKind EKind;
};
@@ -122,6 +124,7 @@ class ObjectFile : public ObjectFileBase, public ELFData<ELFT> {
typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word;
public:
+ using ELFData<ELFT>::getEMachine;
static bool classof(const InputFile *F) {
return F->kind() == ObjectKind &&
@@ -194,6 +197,7 @@ class SharedFile : public SharedFileBase, public ELFData<ELFT> {
std::vector<SharedSymbol<ELFT>> SymbolBodies;
public:
+ using ELFData<ELFT>::getEMachine;
llvm::MutableArrayRef<SharedSymbol<ELFT>> getSharedSymbols() {
return SymbolBodies;
}
OpenPOWER on IntegriCloud