[PATCH] D25090: [Object/ELF] - Check that e_shnum is null when e_shoff is.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 03:15:55 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284371: [Object/ELF] - Check that e_shnum is null when e_shoff is. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25090?vs=73034&id=74823#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25090
Files:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/test/Object/Inputs/invalid-e_shnum.elf
llvm/trunk/test/Object/invalid.test
Index: llvm/trunk/include/llvm/Object/ELF.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELF.h
+++ llvm/trunk/include/llvm/Object/ELF.h
@@ -319,8 +319,12 @@
Header = reinterpret_cast<const Elf_Ehdr *>(base());
- if (Header->e_shoff == 0)
+ if (Header->e_shoff == 0) {
+ if (Header->e_shnum != 0)
+ report_fatal_error(
+ "e_shnum should be zero if a file has no section header table");
return;
+ }
const uint64_t SectionTableOffset = Header->e_shoff;
Index: llvm/trunk/test/Object/invalid.test
===================================================================
--- llvm/trunk/test/Object/invalid.test
+++ llvm/trunk/test/Object/invalid.test
@@ -55,6 +55,9 @@
RUN: not llvm-readobj -t %p/Inputs/invalid-xindex-size.elf 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
INVALID-XINDEX-SIZE: Invalid data was encountered while parsing the file.
+RUN: not llvm-readobj -t %p/Inputs/invalid-e_shnum.elf 2>&1 | FileCheck --check-prefix=INVALID-SH-NUM %s
+INVALID-SH-NUM: e_shnum should be zero if a file has no section header table
+
RUN: not llvm-readobj -t %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
INVALID-EXT-SYMTAB-INDEX: Invalid symbol table index
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25090.74823.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/0d82d3e6/attachment.bin>
More information about the llvm-commits
mailing list