1 # If the offset and/or size fields of the PT_DYNAMIC field become corrupted,
2 # we should report a sensible message.
4 # Creating such a malformed file is hard. The easiest way to simulate it is to
5 # truncate the file. Note that the section headers must first be stripped or
6 # llvm-readobj will fail to parse the file due to the section header table
7 # offset pointing outside the file.
9 # RUN: yaml2obj %s -o %t.base
10 # RUN: llvm-objcopy --strip-sections %t.base %t.stripped
12 # Test case where the size is too large to fit in the file, but the start is
14 # RUN: cp %t.stripped %t.truncated1
15 # RUN: %python -c "with open(r'%t.truncated1', 'r+') as f: f.truncate(0x1001)"
16 # RUN: llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck -DFILE=%t.truncated1 %s
18 # Test case where the offset is too large to be in the file.
19 # RUN: cp %t.stripped %t.truncated2
20 # RUN: %python -c "with open(r'%t.truncated2', 'r+') as f: f.truncate(0xFFF)"
21 # RUN: llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck -DFILE=%t.truncated2 %s
23 # CHECK: warning: '[[FILE]]': PT_DYNAMIC segment offset + size exceeds the size of the file