// 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())
// 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);
}
void scanShlibUndefined();
SymbolBody *find(StringRef Name);
void wrap(StringRef Name);
- ELFFileBase<ELFT> *findFile(SymbolBody *B);
+ InputFile *findFile(SymbolBody *B);
private:
Symbol *insert(SymbolBody *New);
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);
--- /dev/null
+; 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
+}