<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 23, 2015 at 7:37 AM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Wed Sep 23 09:37:01 2015<br>
New Revision: 248382<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248382&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248382&view=rev</a><br>
Log:<br>
Print more information about undefined symbols.<br>
<br>
Modified:<br>
lld/trunk/ELF/Writer.cpp<br>
lld/trunk/test/elf2/undef.s<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248382&r1=248381&r2=248382&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248382&r1=248381&r2=248382&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Wed Sep 23 09:37:01 2015<br>
@@ -288,6 +288,27 @@ void Writer<ELFT>::scanRelocs(const Inpu<br>
}<br>
}<br>
<br>
+template <class ELFT><br>
+static void undefError(const SymbolTable &S, const SymbolBody &Sym) {<br>
+ typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;<br>
+ typedef typename ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range;<br>
+<br>
+ const Elf_Sym &SymE = cast<ELFSymbolBody<ELFT>>(Sym).Sym;<br>
+ ELFFileBase *SymFile = nullptr;<br>
+<br>
+ for (const std::unique_ptr<ObjectFileBase> &F : S.getObjectFiles()) {<br>
+ const auto &File = cast<ObjectFile<ELFT>>(*F);<br>
+ Elf_Sym_Range Syms = File.getObj()->symbols(File.getSymbolTable());<br>
+ if (&SymE > Syms.begin() && &SymE < Syms.end())<br>
+ SymFile = F.get();<br>
+ }<br>
+ if (SymFile)<br>
+ error(Twine("undefined symbol: ") + Sym.getName() + " in " +<br>
+ SymFile->getName());<br>
+ else<br>
+ error(Twine("undefined symbol: ") + Sym.getName());<br></blockquote><div><br></div><div>Under what conditions can we get to here? Internal linker generated symbols?</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
// Create output section objects and add them to OutputSections.<br>
template <class ELFT> void Writer<ELFT>::createSections() {<br>
SmallDenseMap<SectionKey<ELFT::Is64Bits>, OutputSection<ELFT> *> Map;<br>
@@ -331,7 +352,7 @@ template <class ELFT> void Writer<ELFT>:<br>
StringRef Name = P.first;<br>
SymbolBody *Body = P.second->Body;<br>
if (Body->isStrongUndefined())<br>
- error(Twine("undefined symbol: ") + Name);<br>
+ undefError<ELFT>(Symtab, *Body);<br>
<br>
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))<br>
CommonSymbols.push_back(C);<br>
<br>
Modified: lld/trunk/test/elf2/undef.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/undef.s?rev=248382&r1=248381&r2=248382&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/undef.s?rev=248382&r1=248381&r2=248382&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/undef.s (original)<br>
+++ lld/trunk/test/elf2/undef.s Wed Sep 23 09:37:01 2015<br>
@@ -1,6 +1,6 @@<br>
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t<br>
# RUN: not lld -flavor gnu2 %t -o %t2 2>&1 | FileCheck %s<br>
-# CHECK: undefined symbol: foo<br>
+# CHECK: undefined symbol: foo in {{.*}}<br>
# REQUIRES: x86<br>
<br>
.globl _start;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>