From fd5a33d6234323faf8058cbd301bc8f8fb9a522d Mon Sep 17 00:00:00 2001 From: George Rimar Date: Wed, 31 Jan 2018 08:32:35 +0000 Subject: [ELF] - Do not forget file name when reporting duplicate symbol error for absolute symbols. When there is a duplicate absolute symbol, LLD reports instead of known object file name currently. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D42636 llvm-svn: 323849 --- lld/ELF/SymbolTable.cpp | 9 +++++---- lld/test/ELF/abs-conflict.s | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index baf9e205394..c72186c0b81 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -423,11 +423,11 @@ static void reportDuplicate(Symbol *Sym, InputFile *NewFile) { toString(Sym->File) + "\n>>> defined in " + toString(NewFile)); } -static void reportDuplicate(Symbol *Sym, InputSectionBase *ErrSec, - uint64_t ErrOffset) { +static void reportDuplicate(Symbol *Sym, InputFile *NewFile, + InputSectionBase *ErrSec, uint64_t ErrOffset) { Defined *D = cast(Sym); if (!D->Section || !ErrSec) { - reportDuplicate(Sym, ErrSec ? ErrSec->File : nullptr); + reportDuplicate(Sym, NewFile); return; } @@ -467,7 +467,8 @@ Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, uint8_t Type, replaceSymbol(S, File, Name, Binding, StOther, Type, Value, Size, Section); else if (Cmp == 0) - reportDuplicate(S, dyn_cast_or_null(Section), Value); + reportDuplicate(S, File, dyn_cast_or_null(Section), + Value); return S; } diff --git a/lld/test/ELF/abs-conflict.s b/lld/test/ELF/abs-conflict.s index 4662c48a4e4..ea435cc956c 100644 --- a/lld/test/ELF/abs-conflict.s +++ b/lld/test/ELF/abs-conflict.s @@ -15,4 +15,4 @@ foo = 0x123 // DUP: duplicate symbol: foo // DUP-NEXT: >>> defined in {{.*}}.o -// DUP-NEXT: >>> defined in +// DUP-NEXT: >>> defined in {{.*}}2.o -- cgit v1.2.3