Expose ELFFileBase::getEMachine. NFC.

I will use it in a followup patch.

llvm-svn: 248287
This commit is contained in:
Rafael Espindola 2015-09-22 16:53:55 +00:00
parent 126b8b111a
commit 503fe9408d
2 changed files with 11 additions and 8 deletions

View File

@ -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) {

View File

@ -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;
}