diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 427f2fdea53e..7da33feb008b 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -72,6 +72,11 @@ public: Kind kind() const { return FileKind; } + bool isElf() const { + Kind K = kind(); + return K == ObjKind || K == SharedKind; + } + StringRef getName() const { return MB.getBufferIdentifier(); } MemoryBufferRef MB; @@ -121,10 +126,7 @@ public: typedef typename ELFT::SymRange Elf_Sym_Range; ELFFileBase(Kind K, MemoryBufferRef M); - static bool classof(const InputFile *F) { - Kind K = F->kind(); - return K == ObjKind || K == SharedKind; - } + static bool classof(const InputFile *F) { return F->isElf(); } llvm::object::ELFFile getObj() const { return check(llvm::object::ELFFile::create(MB.getBuffer())); diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index c2cf3b3a4b79..173a11668a0a 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -44,8 +44,8 @@ static InputFile *getFirstElf() { // All input object files must be for the same architecture // (e.g. it does not make sense to link x86 object files with // MIPS object files.) This function checks for that error. -template static bool isCompatible(InputFile *F) { - if (!isa>(F) && !isa(F)) +static bool isCompatible(InputFile *F) { + if (!F->isElf() && !isa(F)) return true; if (F->EKind == Config->EKind && F->EMachine == Config->EMachine) { @@ -64,7 +64,7 @@ template static bool isCompatible(InputFile *F) { // Add symbols in File to the symbol table. template void SymbolTable::addFile(InputFile *File) { - if (!isCompatible(File)) + if (!isCompatible(File)) return; // Binary file