[lld] r256867 - Make findFile() a member function of SymbolTable to simplify. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 5 12:01:30 PST 2016
Author: ruiu
Date: Tue Jan 5 14:01:29 2016
New Revision: 256867
URL: http://llvm.org/viewvc/llvm-project?rev=256867&view=rev
Log:
Make findFile() a member function of SymbolTable to simplify. NFC.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=256867&r1=256866&r2=256867&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Jan 5 14:01:29 2016
@@ -124,11 +124,9 @@ template <class ELFT> bool SymbolTable<E
}
// 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<
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<EL
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 *);
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=256867&r1=256866&r2=256867&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Tue Jan 5 14:01:29 2016
@@ -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
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=256867&r1=256866&r2=256867&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jan 5 14:01:29 2016
@@ -330,18 +330,17 @@ void Writer<ELFT>::scanRelocs(InputSecti
}
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>:
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);
More information about the llvm-commits
mailing list