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.
|
// 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>
|
template <class ELFT>
|
||||||
ELFFileBase<ELFT> *
|
ELFFileBase<ELFT> *SymbolTable<ELFT>::findFile(SymbolBody *B) {
|
||||||
elf2::findFile(ArrayRef<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles,
|
|
||||||
const SymbolBody *B) {
|
|
||||||
for (const std::unique_ptr<ObjectFile<ELFT>> &F : ObjectFiles) {
|
for (const std::unique_ptr<ObjectFile<ELFT>> &F : ObjectFiles) {
|
||||||
ArrayRef<SymbolBody *> Syms = F->getSymbols();
|
ArrayRef<SymbolBody *> Syms = F->getSymbols();
|
||||||
if (std::find(Syms.begin(), Syms.end(), B) != Syms.end())
|
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>
|
template <class ELFT>
|
||||||
std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) {
|
std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) {
|
||||||
ELFFileBase<ELFT> *OldFile = findFile<ELFT>(ObjectFiles, Old);
|
ELFFileBase<ELFT> *OldFile = findFile(Old);
|
||||||
ELFFileBase<ELFT> *NewFile = findFile<ELFT>(ObjectFiles, New);
|
ELFFileBase<ELFT> *NewFile = findFile(New);
|
||||||
|
|
||||||
StringRef Sym = Old->getName();
|
StringRef Sym = Old->getName();
|
||||||
StringRef F1 = OldFile ? OldFile->getName() : "(internal)";
|
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<ELF32BE>;
|
||||||
template class lld::elf2::SymbolTable<ELF64LE>;
|
template class lld::elf2::SymbolTable<ELF64LE>;
|
||||||
template class lld::elf2::SymbolTable<ELF64BE>;
|
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);
|
bool isUndefined(StringRef Name);
|
||||||
void scanShlibUndefined();
|
void scanShlibUndefined();
|
||||||
SymbolBody *find(StringRef Name);
|
SymbolBody *find(StringRef Name);
|
||||||
|
ELFFileBase<ELFT> *findFile(SymbolBody *B);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Symbol *insert(SymbolBody *New);
|
Symbol *insert(SymbolBody *New);
|
||||||
|
@ -87,11 +88,6 @@ private:
|
||||||
llvm::DenseSet<StringRef> IncludedSoNames;
|
llvm::DenseSet<StringRef> IncludedSoNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class ELFT>
|
|
||||||
ELFFileBase<ELFT> *
|
|
||||||
findFile(ArrayRef<std::unique_ptr<ObjectFile<ELFT>>> ObjectFiles,
|
|
||||||
const SymbolBody *B);
|
|
||||||
|
|
||||||
} // namespace elf2
|
} // namespace elf2
|
||||||
} // namespace lld
|
} // namespace lld
|
||||||
|
|
||||||
|
|
|
@ -330,18 +330,17 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &S,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
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)
|
if (Config->Shared && !Config->NoUndefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ELFFileBase<ELFT> *SymFile = findFile<ELFT>(S.getObjectFiles(), &Sym);
|
std::string Msg = "undefined symbol: " + Sym->getName().str();
|
||||||
std::string Message = "undefined symbol: " + Sym.getName().str();
|
if (ELFFileBase<ELFT> *File = Symtab.findFile(Sym))
|
||||||
if (SymFile)
|
Msg += " in " + File->getName().str();
|
||||||
Message += " in " + SymFile->getName().str();
|
|
||||||
if (Config->NoInhibitExec)
|
if (Config->NoInhibitExec)
|
||||||
warning(Message);
|
warning(Msg);
|
||||||
else
|
else
|
||||||
error(Message);
|
error(Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local symbols are not in the linker's symbol table. This function scans
|
// 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;
|
SymbolBody *Body = P.second->Body;
|
||||||
if (auto *U = dyn_cast<Undefined>(Body))
|
if (auto *U = dyn_cast<Undefined>(Body))
|
||||||
if (!U->isWeak() && !U->canKeepUndefined())
|
if (!U->isWeak() && !U->canKeepUndefined())
|
||||||
reportUndefined<ELFT>(Symtab, *Body);
|
reportUndefined<ELFT>(Symtab, Body);
|
||||||
|
|
||||||
if (auto *C = dyn_cast<DefinedCommon>(Body))
|
if (auto *C = dyn_cast<DefinedCommon>(Body))
|
||||||
CommonSymbols.push_back(C);
|
CommonSymbols.push_back(C);
|
||||||
|
|
Loading…
Reference in New Issue