[PATCH] D25371: [ELF] - Fixed assertion fail when symbol table has invalid sh_info value.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 10:43:01 PDT 2016


What was the assertion?

Cheers,
Rafael


On 7 October 2016 at 12:05, George Rimar <grimar at accesssoftek.com> wrote:
> grimar created this revision.
> grimar added reviewers: ruiu, rafael, davide.
> grimar added subscribers: llvm-commits, grimar, evgeny777.
>
> This part was splitted from https://reviews.llvm.org/D25016.
>
> When sh_info value was set in the way that non-local symbol was treated as local, lld
> was asserting, patch fixes that.
>
>
> https://reviews.llvm.org/D25371
>
> Files:
>   ELF/Writer.cpp
>   test/ELF/invalid/Inputs/symtab-sh_info3.elf
>   test/ELF/invalid/symtab-sh-info.s
>
>
> Index: test/ELF/invalid/symtab-sh-info.s
> ===================================================================
> --- test/ELF/invalid/symtab-sh-info.s
> +++ test/ELF/invalid/symtab-sh-info.s
> @@ -2,3 +2,8 @@
>  ## so sh_info should be at least 1 in a valid ELF.
>  # RUN: not ld.lld %p/Inputs/symtab-sh_info2.elf -o %t2 2>&1 | FileCheck %s
>  # CHECK: invalid sh_info in symbol table
> +
> +## sh_info contains invalid value saying non-local symbol is local.
> +# RUN: not ld.lld %p/Inputs/symtab-sh_info3.elf -o %t2 2>&1 | \
> +# RUN:   FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s
> +# INVALID-SYMTAB-SHINFO: invalid sh_info in symbol table
> Index: ELF/Writer.cpp
> ===================================================================
> --- ELF/Writer.cpp
> +++ ELF/Writer.cpp
> @@ -364,6 +364,8 @@
>    for (elf::ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles()) {
>      StringRef StrTab = F->getStringTable();
>      for (SymbolBody *B : F->getLocalSymbols()) {
> +      if (!B->IsLocal)
> +        fatal(getFilename(F) + ": invalid sh_info in symbol table");
>        auto *DR = dyn_cast<DefinedRegular<ELFT>>(B);
>        // No reason to keep local undefined symbol in symtab.
>        if (!DR)
>
>


More information about the llvm-commits mailing list