summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/SymbolTable.cpp30
-rw-r--r--lld/ELF/SymbolTable.h1
2 files changed, 15 insertions, 16 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 61826cbf525..ebb13af0577 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -34,9 +34,23 @@ template <class ELFT> bool SymbolTable<ELFT>::shouldUseRela() const {
}
template <class ELFT>
+static void checkCompatibility(InputFile *FileP) {
+ auto *F = dyn_cast<ELFFileBase<ELFT>>(FileP);
+ if (!F)
+ return;
+ if (F->getELFKind() == Config->EKind && F->getEMachine() == Config->EMachine)
+ return;
+ StringRef A = F->getName();
+ StringRef B = Config->Emulation;
+ if (B.empty())
+ B = Config->FirstElf->getName();
+ error(A + " is incompatible with " + B);
+}
+
+template <class ELFT>
void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
- checkCompatibility(File);
InputFile *FileP = File.release();
+ checkCompatibility<ELFT>(FileP);
// .a file
if (auto *F = dyn_cast<ArchiveFile>(FileP)) {
@@ -209,20 +223,6 @@ template <class ELFT> void SymbolTable<ELFT>::addLazy(Lazy *L) {
}
template <class ELFT>
-void SymbolTable<ELFT>::checkCompatibility(std::unique_ptr<InputFile> &File) {
- auto *E = dyn_cast<ELFFileBase<ELFT>>(File.get());
- if (!E)
- return;
- if (E->getELFKind() == Config->EKind && E->getEMachine() == Config->EMachine)
- return;
- StringRef A = E->getName();
- StringRef B = Config->Emulation;
- if (B.empty())
- B = Config->FirstElf->getName();
- error(A + " is incompatible with " + B);
-}
-
-template <class ELFT>
void SymbolTable<ELFT>::addMemberFile(Undefined<ELFT> *Undef, Lazy *L) {
// Weak undefined symbols should not fetch members from archives.
// If we were to keep old symbol we would not know that an archive member was
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index a6b478a75d1..e14f32cb865 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -65,7 +65,6 @@ private:
Symbol *insert(SymbolBody *New);
void addLazy(Lazy *New);
void addMemberFile(Undefined<ELFT> *Undef, Lazy *L);
- void checkCompatibility(std::unique_ptr<InputFile> &File);
void resolve(SymbolBody *Body);
std::string conflictMsg(SymbolBody *Old, SymbolBody *New);
OpenPOWER on IntegriCloud