[lld] r283562 - [ELF] - Fixed assert fail when symbol table has zero sh_info value.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 08:16:27 PDT 2016
Author: grimar
Date: Fri Oct 7 10:16:27 2016
New Revision: 283562
URL: http://llvm.org/viewvc/llvm-project?rev=283562&view=rev
Log:
[ELF] - Fixed assert fail when symbol table has zero sh_info value.
When sh_info of sumbol table value was set to zero, lld was asserting.
Patch fixes the issue.
Differential revision: https://reviews.llvm.org/D25016
Added:
lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info2.elf (with props)
lld/trunk/test/ELF/invalid/symtab-sh-info.s
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=283562&r1=283561&r2=283562&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Oct 7 10:16:27 2016
@@ -81,7 +81,7 @@ typename ELFT::SymRange ELFFileBase<ELFT
Elf_Sym_Range Syms = ELFObj.symbols(Symtab);
uint32_t NumSymbols = std::distance(Syms.begin(), Syms.end());
uint32_t FirstNonLocal = Symtab->sh_info;
- if (FirstNonLocal > NumSymbols)
+ if (FirstNonLocal == 0 || FirstNonLocal > NumSymbols)
fatal(getFilename(this) + ": invalid sh_info in symbol table");
if (OnlyGlobals)
Added: lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info2.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info2.elf?rev=283562&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info2.elf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: lld/trunk/test/ELF/invalid/symtab-sh-info.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/symtab-sh-info.s?rev=283562&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/symtab-sh-info.s (added)
+++ lld/trunk/test/ELF/invalid/symtab-sh-info.s Fri Oct 7 10:16:27 2016
@@ -0,0 +1,4 @@
+## sh_info contains zero value. First entry in a symbol table is always completely zeroed,
+## 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
More information about the llvm-commits
mailing list