diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-01-05 20:01:29 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-01-05 20:01:29 +0000 |
| commit | 2a65a49bcf99c720fb81ff69c3b955ee5f89770d (patch) | |
| tree | 38004fc5c7788c68d19ce50e6ca78cd248f2678b | |
| parent | 2e83790c37bd53c89389b59bc51bfcf7c33b688f (diff) | |
| download | bcm5719-llvm-2a65a49bcf99c720fb81ff69c3b955ee5f89770d.tar.gz bcm5719-llvm-2a65a49bcf99c720fb81ff69c3b955ee5f89770d.zip | |
Make findFile() a member function of SymbolTable to simplify. NFC.
llvm-svn: 256867
| -rw-r--r-- | lld/ELF/SymbolTable.cpp | 23 | ||||
| -rw-r--r-- | lld/ELF/SymbolTable.h | 6 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 15 |
3 files changed, 12 insertions, 32 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index e022ecd2e90..89ddfe969e3 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -124,11 +124,9 @@ template <class ELFT> bool SymbolTable<ELFT>::isUndefined(StringRef Name) { } // Returns a file from which symbol B was created. -// If B does not belong to any file in ObjectFiles, returns a nullptr. +// If B does not belong to any file, returns a nullptr. template <class ELFT> -ELFFileBase<ELFT> * -elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles, - const SymbolBody *B) { +ELFFileBase<ELFT> *SymbolTable<ELFT>::findFile(SymbolBody *B) { for (const std::unique_ptr<ObjectFile<ELFT>> &F : ObjectFiles) { ArrayRef<SymbolBody *> Syms = F->getSymbols(); if (std::find(Syms.begin(), Syms.end(), B) != Syms.end()) @@ -139,8 +137,8 @@ elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles, template <class ELFT> std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) { - ELFFileBase<ELFT> *OldFile = findFile<ELFT>(ObjectFiles, Old); - ELFFileBase<ELFT> *NewFile = findFile<ELFT>(ObjectFiles, New); + ELFFileBase<ELFT> *OldFile = findFile(Old); + ELFFileBase<ELFT> *NewFile = findFile(New); StringRef Sym = Old->getName(); StringRef F1 = OldFile ? OldFile->getName() : "(internal)"; @@ -252,16 +250,3 @@ template class lld::elf2::SymbolTable<ELF32LE>; template class lld::elf2::SymbolTable<ELF32BE>; template class lld::elf2::SymbolTable<ELF64LE>; template class lld::elf2::SymbolTable<ELF64BE>; - -template ELFFileBase<ELF32LE> * -lld::elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELF32LE>>>, - const SymbolBody *); -template ELFFileBase<ELF32BE> * -lld::elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELF32BE>>>, - const SymbolBody *); -template ELFFileBase<ELF64LE> * -lld::elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELF64LE>>>, - const SymbolBody *); -template ELFFileBase<ELF64BE> * -lld::elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELF64BE>>>, - const SymbolBody *); diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index aa905e027d4..1bd85abede6 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -58,6 +58,7 @@ public: bool isUndefined(StringRef Name); void scanShlibUndefined(); SymbolBody *find(StringRef Name); + ELFFileBase<ELFT> *findFile(SymbolBody *B); private: Symbol *insert(SymbolBody *New); @@ -87,11 +88,6 @@ private: llvm::DenseSet<StringRef> IncludedSoNames; }; -template <class ELFT> -ELFFileBase<ELFT> * -findFile(ArrayRef<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles, - const SymbolBody *B); - } // namespace elf2 } // namespace lld diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 0fff0b20abd..0c3752ee52d 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -330,18 +330,17 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &S, } template <class ELFT> -static void reportUndefined(const SymbolTable<ELFT> &S, const SymbolBody &Sym) { +static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) { if (Config->Shared && !Config->NoUndefined) return; - ELFFileBase<ELFT> *SymFile = findFile<ELFT>(S.getObjectFiles(), &Sym); - std::string Message = "undefined symbol: " + Sym.getName().str(); - if (SymFile) - Message += " in " + SymFile->getName().str(); + std::string Msg = "undefined symbol: " + Sym->getName().str(); + if (ELFFileBase<ELFT> *File = Symtab.findFile(Sym)) + Msg += " in " + File->getName().str(); if (Config->NoInhibitExec) - warning(Message); + warning(Msg); else - error(Message); + error(Msg); } // Local symbols are not in the linker's symbol table. This function scans @@ -801,7 +800,7 @@ template <class ELFT> void Writer<ELFT>::createSections() { SymbolBody *Body = P.second->Body; if (auto *U = dyn_cast<Undefined>(Body)) if (!U->isWeak() && !U->canKeepUndefined()) - reportUndefined<ELFT>(Symtab, *Body); + reportUndefined<ELFT>(Symtab, Body); if (auto *C = dyn_cast<DefinedCommon>(Body)) CommonSymbols.push_back(C); |

