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