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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 15:05:47 PST 2018


LGTM

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
> grimar added reviewers: ruiu, espindola.
> Herald added a subscriber: emaste.
>
> When there is a duplicate absolute symbol, LLD reports `<internal>`
> instead of known object file name currently.
> Patch fixes the issue.
>
>
> https://reviews.llvm.org/D42636
>
> Files:
>   ELF/SymbolTable.cpp
>   test/ELF/abs-conflict.s
>
>
> Index: test/ELF/abs-conflict.s
> ===================================================================
> --- test/ELF/abs-conflict.s
> +++ test/ELF/abs-conflict.s
> @@ -15,4 +15,4 @@
>  
>  // DUP:      duplicate symbol: foo
>  // DUP-NEXT: >>> defined in {{.*}}.o
> -// DUP-NEXT: >>> defined in <internal>
> +// DUP-NEXT: >>> defined in {{.*}}2.o
> Index: ELF/SymbolTable.cpp
> ===================================================================
> --- ELF/SymbolTable.cpp
> +++ ELF/SymbolTable.cpp
> @@ -423,11 +423,11 @@
>                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 @@
>      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;
>  }
>  
>
>
> Index: test/ELF/abs-conflict.s
> ===================================================================
> --- test/ELF/abs-conflict.s
> +++ test/ELF/abs-conflict.s
> @@ -15,4 +15,4 @@
>  
>  // DUP:      duplicate symbol: foo
>  // DUP-NEXT: >>> defined in {{.*}}.o
> -// DUP-NEXT: >>> defined in <internal>
> +// DUP-NEXT: >>> defined in {{.*}}2.o
> Index: ELF/SymbolTable.cpp
> ===================================================================
> --- ELF/SymbolTable.cpp
> +++ ELF/SymbolTable.cpp
> @@ -423,11 +423,11 @@
>                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 @@
>      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;
>  }
>  


More information about the llvm-commits mailing list