forked from OSchip/llvm-project
Print more information about undefined symbols.
llvm-svn: 248382
This commit is contained in:
parent
8e5560d894
commit
6173f848b9
|
|
@ -288,6 +288,27 @@ void Writer<ELFT>::scanRelocs(const InputSection<ELFT> &C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class ELFT>
|
||||||
|
static void undefError(const SymbolTable &S, const SymbolBody &Sym) {
|
||||||
|
typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
|
||||||
|
typedef typename ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range;
|
||||||
|
|
||||||
|
const Elf_Sym &SymE = cast<ELFSymbolBody<ELFT>>(Sym).Sym;
|
||||||
|
ELFFileBase *SymFile = nullptr;
|
||||||
|
|
||||||
|
for (const std::unique_ptr<ObjectFileBase> &F : S.getObjectFiles()) {
|
||||||
|
const auto &File = cast<ObjectFile<ELFT>>(*F);
|
||||||
|
Elf_Sym_Range Syms = File.getObj()->symbols(File.getSymbolTable());
|
||||||
|
if (&SymE > Syms.begin() && &SymE < Syms.end())
|
||||||
|
SymFile = F.get();
|
||||||
|
}
|
||||||
|
if (SymFile)
|
||||||
|
error(Twine("undefined symbol: ") + Sym.getName() + " in " +
|
||||||
|
SymFile->getName());
|
||||||
|
else
|
||||||
|
error(Twine("undefined symbol: ") + Sym.getName());
|
||||||
|
}
|
||||||
|
|
||||||
// Create output section objects and add them to OutputSections.
|
// Create output section objects and add them to OutputSections.
|
||||||
template <class ELFT> void Writer<ELFT>::createSections() {
|
template <class ELFT> void Writer<ELFT>::createSections() {
|
||||||
SmallDenseMap<SectionKey<ELFT::Is64Bits>, OutputSection<ELFT> *> Map;
|
SmallDenseMap<SectionKey<ELFT::Is64Bits>, OutputSection<ELFT> *> Map;
|
||||||
|
|
@ -331,7 +352,7 @@ template <class ELFT> void Writer<ELFT>::createSections() {
|
||||||
StringRef Name = P.first;
|
StringRef Name = P.first;
|
||||||
SymbolBody *Body = P.second->Body;
|
SymbolBody *Body = P.second->Body;
|
||||||
if (Body->isStrongUndefined())
|
if (Body->isStrongUndefined())
|
||||||
error(Twine("undefined symbol: ") + Name);
|
undefError<ELFT>(Symtab, *Body);
|
||||||
|
|
||||||
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
|
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
|
||||||
CommonSymbols.push_back(C);
|
CommonSymbols.push_back(C);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||||
# RUN: not lld -flavor gnu2 %t -o %t2 2>&1 | FileCheck %s
|
# RUN: not lld -flavor gnu2 %t -o %t2 2>&1 | FileCheck %s
|
||||||
# CHECK: undefined symbol: foo
|
# CHECK: undefined symbol: foo in {{.*}}
|
||||||
# REQUIRES: x86
|
# REQUIRES: x86
|
||||||
|
|
||||||
.globl _start;
|
.globl _start;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue