[lld] r248380 - Print more information about duplicated symbols.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 18:25:29 PDT 2015


On Wed, Sep 23, 2015 at 7:10 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Wed Sep 23 09:10:24 2015
> New Revision: 248380
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248380&view=rev
> Log:
> Print more information about duplicated symbols.
>
> Modified:
>     lld/trunk/ELF/SymbolTable.cpp
>     lld/trunk/ELF/SymbolTable.h
>     lld/trunk/test/elf2/basic.s
>
> Modified: lld/trunk/ELF/SymbolTable.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=248380&r1=248379&r2=248380&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/SymbolTable.cpp (original)
> +++ lld/trunk/ELF/SymbolTable.cpp Wed Sep 23 09:10:24 2015
> @@ -101,6 +101,29 @@ void SymbolTable::addELFFile(ELFFileBase
>    }
>  }
>
> +template <class ELFT>
> +void SymbolTable::dupErorr(const SymbolBody &Old, const SymbolBody &New) {
>

Typo: Erorr

-- Sean Silva


> +  typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
> +  typedef typename ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range;
> +
> +  const Elf_Sym &OldE = cast<ELFSymbolBody<ELFT>>(Old).Sym;
> +  const Elf_Sym &NewE = cast<ELFSymbolBody<ELFT>>(New).Sym;
> +  ELFFileBase *OldFile = nullptr;
> +  ELFFileBase *NewFile = nullptr;
> +
> +  for (const std::unique_ptr<ObjectFileBase> &F : ObjectFiles) {
> +    const auto &File = cast<ObjectFile<ELFT>>(*F);
> +    Elf_Sym_Range Syms = File.getObj()->symbols(File.getSymbolTable());
> +    if (&OldE > Syms.begin() && &OldE < Syms.end())
> +      OldFile = F.get();
> +    if (&NewE > Syms.begin() && &NewE < Syms.end())
> +      NewFile = F.get();
> +  }
> +
> +  error(Twine("duplicate symbol: ") + Old.getName() + " in " +
> +        OldFile->getName() + " and " + NewFile->getName());
> +}
> +
>  // This function resolves conflicts if there's an existing symbol with
>  // the same name. Decisions are made based on symbol type.
>  template <class ELFT> void SymbolTable::resolve(SymbolBody *New) {
> @@ -127,8 +150,8 @@ template <class ELFT> void SymbolTable::
>    int comp = Existing->compare<ELFT>(New);
>    if (comp < 0)
>      Sym->Body = New;
> -  if (comp == 0)
> -    error(Twine("duplicate symbol: ") + Sym->Body->getName());
> +  else if (comp == 0)
> +    dupErorr<ELFT>(*Existing, *New);
>  }
>
>  Symbol *SymbolTable::insert(SymbolBody *New) {
>
> Modified: lld/trunk/ELF/SymbolTable.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=248380&r1=248379&r2=248380&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/SymbolTable.h (original)
> +++ lld/trunk/ELF/SymbolTable.h Wed Sep 23 09:10:24 2015
> @@ -70,6 +70,8 @@ private:
>
>    template <class ELFT> void init(uint16_t EMachine);
>    template <class ELFT> void resolve(SymbolBody *Body);
> +  template <class ELFT>
> +  void dupErorr(const SymbolBody &Old, const SymbolBody &New);
>
>    std::vector<std::unique_ptr<ArchiveFile>> ArchiveFiles;
>
>
> Modified: lld/trunk/test/elf2/basic.s
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=248380&r1=248379&r2=248380&view=diff
>
> ==============================================================================
> --- lld/trunk/test/elf2/basic.s (original)
> +++ lld/trunk/test/elf2/basic.s Wed Sep 23 09:10:24 2015
> @@ -199,4 +199,4 @@ _start:
>
>  # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
>  # RUN: not lld -flavor gnu2 %t %t -o %t2 2>&1 | FileCheck
> --check-prefix=DUP %s
> -# DUP: duplicate symbol: _start
> +# DUP: duplicate symbol: _start in {{.*}} and {{.*}}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150923/8a69e9e7/attachment.html>


More information about the llvm-commits mailing list