[ELF] - Do not forget file name when reporting duplicate symbol error for absolute symbols.

When there is a duplicate absolute symbol, LLD reports <internal>
instead of known object file name currently.
Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D42636

llvm-svn: 323849
This commit is contained in:
George Rimar 2018-01-31 08:32:35 +00:00
parent 7f9c518423
commit fd5a33d623
2 changed files with 6 additions and 5 deletions

View File

@ -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<Defined>(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<Defined>(S, File, Name, Binding, StOther, Type, Value, Size,
Section);
else if (Cmp == 0)
reportDuplicate(S, dyn_cast_or_null<InputSectionBase>(Section), Value);
reportDuplicate(S, File, dyn_cast_or_null<InputSectionBase>(Section),
Value);
return S;
}

View File

@ -15,4 +15,4 @@ foo = 0x123
// DUP: duplicate symbol: foo
// DUP-NEXT: >>> defined in {{.*}}.o
// DUP-NEXT: >>> defined in <internal>
// DUP-NEXT: >>> defined in {{.*}}2.o