<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 23, 2015 at 7:10 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:10:24 2015<br>
New Revision: 248380<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248380&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248380&view=rev</a><br>
Log:<br>
Print more information about duplicated symbols.<br>
<br>
Modified:<br>
    lld/trunk/ELF/SymbolTable.cpp<br>
    lld/trunk/ELF/SymbolTable.h<br>
    lld/trunk/test/elf2/basic.s<br></blockquote><div><br></div><div>There's only one ELF linker in LLD now, right? Should we rename the test directory (and any lingering remnants) to ELF, dropping the '2' suffix, now?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=248380&r1=248379&r2=248380&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=248380&r1=248379&r2=248380&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Wed Sep 23 09:10:24 2015<br>
@@ -101,6 +101,29 @@ void SymbolTable::addELFFile(ELFFileBase<br>
   }<br>
 }<br>
<br>
+template <class ELFT><br>
+void SymbolTable::dupErorr(const SymbolBody &Old, const SymbolBody &New) {<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 &OldE = cast<ELFSymbolBody<ELFT>>(Old).Sym;<br>
+  const Elf_Sym &NewE = cast<ELFSymbolBody<ELFT>>(New).Sym;<br>
+  ELFFileBase *OldFile = nullptr;<br>
+  ELFFileBase *NewFile = nullptr;<br>
+<br>
+  for (const std::unique_ptr<ObjectFileBase> &F : ObjectFiles) {<br>
+    const auto &File = cast<ObjectFile<ELFT>>(*F);<br>
+    Elf_Sym_Range Syms = File.getObj()->symbols(File.getSymbolTable());<br>
+    if (&OldE > Syms.begin() && &OldE < Syms.end())<br>
+      OldFile = F.get();<br>
+    if (&NewE > Syms.begin() && &NewE < Syms.end())<br>
+      NewFile = F.get();<br>
+  }<br>
+<br>
+  error(Twine("duplicate symbol: ") + Old.getName() + " in " +<br>
+        OldFile->getName() + " and " + NewFile->getName());<br>
+}<br>
+<br>
 // This function resolves conflicts if there's an existing symbol with<br>
 // the same name. Decisions are made based on symbol type.<br>
 template <class ELFT> void SymbolTable::resolve(SymbolBody *New) {<br>
@@ -127,8 +150,8 @@ template <class ELFT> void SymbolTable::<br>
   int comp = Existing->compare<ELFT>(New);<br>
   if (comp < 0)<br>
     Sym->Body = New;<br>
-  if (comp == 0)<br>
-    error(Twine("duplicate symbol: ") + Sym->Body->getName());<br>
+  else if (comp == 0)<br>
+    dupErorr<ELFT>(*Existing, *New);<br>
 }<br>
<br>
 Symbol *SymbolTable::insert(SymbolBody *New) {<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=248380&r1=248379&r2=248380&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=248380&r1=248379&r2=248380&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/SymbolTable.h (original)<br>
+++ lld/trunk/ELF/SymbolTable.h Wed Sep 23 09:10:24 2015<br>
@@ -70,6 +70,8 @@ private:<br>
<br>
   template <class ELFT> void init(uint16_t EMachine);<br>
   template <class ELFT> void resolve(SymbolBody *Body);<br>
+  template <class ELFT><br>
+  void dupErorr(const SymbolBody &Old, const SymbolBody &New);<br>
<br>
   std::vector<std::unique_ptr<ArchiveFile>> ArchiveFiles;<br>
<br>
<br>
Modified: lld/trunk/test/elf2/basic.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=248380&r1=248379&r2=248380&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=248380&r1=248379&r2=248380&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic.s (original)<br>
+++ lld/trunk/test/elf2/basic.s Wed Sep 23 09:10:24 2015<br>
@@ -199,4 +199,4 @@ _start:<br>
<br>
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t<br>
 # RUN: not lld -flavor gnu2 %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s<br>
-# DUP: duplicate symbol: _start<br>
+# DUP: duplicate symbol: _start in {{.*}} and {{.*}}<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>