Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -379,11 +379,11 @@ template static void reportDuplicate(SymbolBody *Existing, - InputSectionBase *ErrSec, + InputSectionBase *ErrSec, InputFile *File, typename ELFT::uint ErrOffset) { DefinedRegular *D = dyn_cast>(Existing); if (!D || !D->Section || !ErrSec) { - reportDuplicate(Existing, ErrSec ? ErrSec->getFile() : nullptr); + reportDuplicate(Existing, File); return; } @@ -418,7 +418,7 @@ replaceBody>(S, Name, StOther, Type, Value, Size, Section, File); else if (Cmp == 0) - reportDuplicate(S->body(), Section, Value); + reportDuplicate(S->body(), Section, File, Value); return S; } Index: test/ELF/invalid/report-duplicates.test =================================================================== --- test/ELF/invalid/report-duplicates.test +++ test/ELF/invalid/report-duplicates.test @@ -0,0 +1,28 @@ +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld %t.o -o %tout 2>&1 | FileCheck %s +# CHECK: duplicate symbol '' in {{.*}}.o and {{.*}}.o + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Content: "00000000" + - Name: .rela.text + Type: SHT_RELA + Link: .symtab + AddressAlign: 0x0000000000000008 + Info: .text + Relocations: +Symbols: + Global: + - Type: STT_SECTION + Section: .rela.text + - Type: STT_SECTION + Section: .rela.text