<div dir="ltr">Thank you for doing this. This is a nice change as it eliminated a use of template.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 26, 2016 at 1:49 PM, 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: Fri Feb 26 15:49:38 2016<br>
New Revision: 262076<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=262076&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=262076&view=rev</a><br>
Log:<br>
Report duplicated symbols in bitcode.<br>
<br>
Added:<br>
    lld/trunk/test/ELF/lto/duplicated.ll<br>
Modified:<br>
    lld/trunk/ELF/SymbolTable.cpp<br>
    lld/trunk/ELF/SymbolTable.h<br>
    lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=262076&r1=262075&r2=262076&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=262076&r1=262075&r2=262076&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Fri Feb 26 15:49:38 2016<br>
@@ -217,18 +217,22 @@ template <class ELFT> void SymbolTable<E<br>
<br>
 // Returns a file from which symbol B was created.<br>
 // If B does not belong to any file, returns a nullptr.<br>
-template <class ELFT><br>
-ELFFileBase<ELFT> *SymbolTable<ELFT>::findFile(SymbolBody *B) {<br>
+template <class ELFT> InputFile *SymbolTable<ELFT>::findFile(SymbolBody *B) {<br>
   for (const std::unique_ptr<ObjectFile<ELFT>> &F : ObjectFiles) {<br>
     ArrayRef<SymbolBody *> Syms = F->getSymbols();<br>
     if (std::find(Syms.begin(), Syms.end(), B) != Syms.end())<br>
       return F.get();<br>
   }<br>
+  for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles) {<br>
+    ArrayRef<SymbolBody *> Syms = F->getSymbols();<br>
+    if (std::find(Syms.begin(), Syms.end(), B) != Syms.end())<br>
+      return F.get();<br>
+  }<br>
   return nullptr;<br>
 }<br>
<br>
 // Returns "(internal)", "foo.a(bar.o)" or "baz.o".<br>
-template <class ELFT> static std::string getFilename(ELFFileBase<ELFT> *F) {<br>
+static std::string getFilename(InputFile *F) {<br>
   if (!F)<br>
     return "(internal)";<br>
   if (!F->ArchiveName.empty())<br>
@@ -240,8 +244,8 @@ template <class ELFT> static std::string<br>
 // Used to construct an error message.<br>
 template <class ELFT><br>
 std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) {<br>
-  ELFFileBase<ELFT> *F1 = findFile(Old);<br>
-  ELFFileBase<ELFT> *F2 = findFile(New);<br>
+  InputFile *F1 = findFile(Old);<br>
+  InputFile *F2 = findFile(New);<br>
   StringRef Sym = Old->getName();<br>
   return demangle(Sym) + " in " + getFilename(F1) + " and " + getFilename(F2);<br>
 }<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=262076&r1=262075&r2=262076&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=262076&r1=262075&r2=262076&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/SymbolTable.h (original)<br>
+++ lld/trunk/ELF/SymbolTable.h Fri Feb 26 15:49:38 2016<br>
@@ -64,7 +64,7 @@ public:<br>
   void scanShlibUndefined();<br>
   SymbolBody *find(StringRef Name);<br>
   void wrap(StringRef Name);<br>
-  ELFFileBase<ELFT> *findFile(SymbolBody *B);<br>
+  InputFile *findFile(SymbolBody *B);<br>
<br>
 private:<br>
   Symbol *insert(SymbolBody *New);<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262076&r1=262075&r2=262076&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262076&r1=262075&r2=262076&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Fri Feb 26 15:49:38 2016<br>
@@ -517,7 +517,7 @@ static void reportUndefined(SymbolTable<<br>
     return;<br>
<br>
   std::string Msg = "undefined symbol: " + Sym->getName().str();<br>
-  if (ELFFileBase<ELFT> *File = Symtab.findFile(Sym))<br>
+  if (InputFile *File = Symtab.findFile(Sym))<br>
     Msg += " in " + File->getName().str();<br>
   if (Config->NoInhibitExec)<br>
     warning(Msg);<br>
<br>
Added: lld/trunk/test/ELF/lto/duplicated.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/duplicated.ll?rev=262076&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/duplicated.ll?rev=262076&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/test/ELF/lto/duplicated.ll (added)<br>
+++ lld/trunk/test/ELF/lto/duplicated.ll Fri Feb 26 15:49:38 2016<br>
@@ -0,0 +1,10 @@<br>
+; REQUIRES: x86<br>
+; RUN: llvm-as %s -o %t.o<br>
+; RUN: not ld.lld -m elf_x86_64 %t.o %t.o -o %t.so -shared 2>&1 | FileCheck %s<br>
+; CHECK: duplicate symbol: f in {{.*}}.o and {{.*}}.o<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
+<br>
+define void @f() {<br>
+  ret void<br>
+}<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>