[Object/ELF] - Check that e_shnum is null when e_shoff is.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 17 Oct 2016 10:06:44 +0000 (10:06 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 17 Oct 2016 10:06:44 +0000 (10:06 +0000)
commit7d97e735892b478bde261c6a2f197c6deec1e18c
tree87f987f306336d001b66d2263b41abbd390f0b1b
parentbd31488083f3d3db2603464026853d528cfdc07e
[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: 284371
llvm/include/llvm/Object/ELF.h
llvm/test/Object/Inputs/invalid-e_shnum.elf [new file with mode: 0644]
llvm/test/Object/invalid.test