[lld] r284375 - [ELF] - Added testcase relative to D25090.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 04:15:13 PDT 2016


Author: grimar
Date: Mon Oct 17 06:15:12 2016
New Revision: 284375

URL: http://llvm.org/viewvc/llvm-project?rev=284375&view=rev
Log:
[ELF] - Added testcase relative to D25090.

It was requested on review for https://reviews.llvm.org/D25090 to add testcase in lld.

Spec says (http://www.sco.com/developers/gabi/1998-04-29/ch4.eheader.html) :
e_shnum
This member holds the number of entries in the section header table. 
Thus the product of e_shentsize and e_shnum gives the section header table's size in bytes.
If a file has no section header table, e_shnum holds the value zero.

In case revealed, broken input did not contain zero in this field.
 LLD then could crash when proccessed sections (returned array has incorrect size):

template <class ELFT> void SharedFile<ELFT>::parseSoName() {
...
  for (const Elf_Shdr &Sec : Obj.sections()) {
...




Added:
    lld/trunk/test/ELF/invalid/Inputs/invalid-e_shnum.elf   (with props)
    lld/trunk/test/ELF/invalid/invalid-e_shnum.s

Added: lld/trunk/test/ELF/invalid/Inputs/invalid-e_shnum.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/invalid-e_shnum.elf?rev=284375&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lld/trunk/test/ELF/invalid/Inputs/invalid-e_shnum.elf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lld/trunk/test/ELF/invalid/invalid-e_shnum.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/invalid-e_shnum.s?rev=284375&view=auto
==============================================================================
--- lld/trunk/test/ELF/invalid/invalid-e_shnum.s (added)
+++ lld/trunk/test/ELF/invalid/invalid-e_shnum.s Mon Oct 17 06:15:12 2016
@@ -0,0 +1,4 @@
+## Spec says that "If a file has no section header table, e_shnum holds the value zero.", though
+## in this test case it holds non-zero and lld may crash.
+# RUN: not ld.lld %p/Inputs/invalid-e_shnum.elf -o %t2 2>&1 | FileCheck %s
+# CHECK: e_shnum should be zero if a file has no section header table
\ No newline at end of file




More information about the llvm-commits mailing list