Recommit r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 17 Oct 2016 10:58:02 +0000 (10:58 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 17 Oct 2016 10:58:02 +0000 (10:58 +0000)
commit65807f899b4616d3961e14e2cf4a7330eade19de
tree021df44e544a673956558d442d491b503ef81de4
parent830a62aa3954ad1e924c42c1ac85e6b84b4973ae
Recommit r284371 "[Object/ELF] - Check that e_shnum is null when e_shoff is."
With fix: hex edited the precompiled inputs from another testcases to pass new checks.

Original commit message:

[Object/ELF] - Check that e_shnum is null when e_shoff is.

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.

Revealed using "id_000037,sig_11,src_000015,op_havoc,rep_8" from PR30540

That was the reason of crash in lld on incorrect input file.
Binary reduced using afl-min.

Differential revision: https://reviews.llvm.org/D25090

llvm-svn: 284374
llvm/include/llvm/Object/ELF.h
llvm/test/Object/Inputs/corrupt-invalid-strtab.elf.x86-64
llvm/test/Object/Inputs/invalid-e_shnum.elf [new file with mode: 0644]
llvm/test/Object/Inputs/rel-no-sec-table.elf-x86-64
llvm/test/Object/invalid.test