[PATCH] D66036: [llvm-readobj] Downgrade 'PT_DYNAMIC segment offset + size exceeds the size of the file' from an error to a warning
Jordan Rupprecht via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 15:41:43 PDT 2019
rupprecht created this revision.
rupprecht added reviewers: jhenderson, grimar, MaskRay.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This allows llvm-readobj to print other useful information for truncated files instead of giving up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D66036
Files:
llvm/test/Object/invalid.test
llvm/test/tools/llvm-readobj/elf-malformed-pt-dynamic.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1439,9 +1439,11 @@
return;
if (DynamicPhdr->p_offset + DynamicPhdr->p_filesz >
- ObjF->getMemoryBufferRef().getBufferSize())
- reportError(
+ ObjF->getMemoryBufferRef().getBufferSize()) {
+ reportWarning(
"PT_DYNAMIC segment offset + size exceeds the size of the file");
+ return;
+ }
if (!DynamicSec) {
DynamicTable = createDRIFrom(DynamicPhdr, sizeof(Elf_Dyn));
Index: llvm/test/tools/llvm-readobj/elf-malformed-pt-dynamic.test
===================================================================
--- llvm/test/tools/llvm-readobj/elf-malformed-pt-dynamic.test
+++ llvm/test/tools/llvm-readobj/elf-malformed-pt-dynamic.test
@@ -13,14 +13,14 @@
# within the file.
# RUN: cp %t.stripped %t.truncated1
# RUN: %python -c "with open(r'%t.truncated1', 'r+') as f: f.truncate(0x1001)"
-# RUN: not llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck %s
+# RUN: llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck %s
# Test case where the offset is too large to be in the file.
# RUN: cp %t.stripped %t.truncated2
# RUN: %python -c "with open(r'%t.truncated2', 'r+') as f: f.truncate(0xFFF)"
-# RUN: not llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck %s
+# RUN: llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck %s
-# CHECK: error: PT_DYNAMIC segment offset + size exceeds the size of the file
+# CHECK: warning: PT_DYNAMIC segment offset + size exceeds the size of the file
--- !ELF
FileHeader:
Index: llvm/test/Object/invalid.test
===================================================================
--- llvm/test/Object/invalid.test
+++ llvm/test/Object/invalid.test
@@ -489,9 +489,9 @@
## than the object size. Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=23 -o %t23
-# RUN: not llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck --check-prefix=DYN-TABLE-PHDR %s
+# RUN: llvm-readobj --dyn-relocations %t23 2>&1 | FileCheck --check-prefix=DYN-TABLE-PHDR %s
-# DYN-TABLE-PHDR: error: PT_DYNAMIC segment offset + size exceeds the size of the file
+# DYN-TABLE-PHDR: warning: PT_DYNAMIC segment offset + size exceeds the size of the file
--- !ELF
FileHeader:
@@ -515,7 +515,7 @@
## than the object size. Check llvm-readobj reports it.
# RUN: yaml2obj %s --docnum=24 -o %t24
-# RUN: not llvm-readobj --dyn-relocations %t24 2>&1 \
+# RUN: llvm-readobj --dyn-relocations %t24 2>&1 \
# RUN: | FileCheck --check-prefix=DYN-TABLE-PHDR %s
--- !ELF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66036.214469.patch
Type: text/x-patch
Size: 2670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190809/a29ec6f3/attachment-0001.bin>
More information about the llvm-commits
mailing list