summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-10-17 11:15:12 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-10-17 11:15:12 +0000
commit21cd1a6fa98923437077b008416cd34c51be042c (patch)
tree251d8c58bbe0eb788fa0832c04bd7916ac69305d
parent65807f899b4616d3961e14e2cf4a7330eade19de (diff)
downloadbcm5719-llvm-21cd1a6fa98923437077b008416cd34c51be042c.tar.gz
bcm5719-llvm-21cd1a6fa98923437077b008416cd34c51be042c.zip
[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()) { ... llvm-svn: 284375
-rw-r--r--lld/test/ELF/invalid/Inputs/invalid-e_shnum.elfbin0 -> 64 bytes
-rw-r--r--lld/test/ELF/invalid/invalid-e_shnum.s4
2 files changed, 4 insertions, 0 deletions
diff --git a/lld/test/ELF/invalid/Inputs/invalid-e_shnum.elf b/lld/test/ELF/invalid/Inputs/invalid-e_shnum.elf
new file mode 100644
index 00000000000..0b46fbd8cec
--- /dev/null
+++ b/lld/test/ELF/invalid/Inputs/invalid-e_shnum.elf
Binary files differ
diff --git a/lld/test/ELF/invalid/invalid-e_shnum.s b/lld/test/ELF/invalid/invalid-e_shnum.s
new file mode 100644
index 00000000000..fc197e7f285
--- /dev/null
+++ b/lld/test/ELF/invalid/invalid-e_shnum.s
@@ -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
OpenPOWER on IntegriCloud