Make findFile() a member function of SymbolTable to simplify. NFC.
llvm-svn: 256867
This commit is contained in:
parent
2e83790c37
commit
2a65a49bcf
|
@ -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 *);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue