mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Revert "[llvm-readobj/elf] - Refine the code for broken PT_DYNAMIC segment diagnostic."
This reverts commit 455d5a8a065b4b93df11d1696dc1546c403465a5. It broke UBSan: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/21386/steps/check-llvm%20ubsan/logs/stdio /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-readobj/ELF/malformed-pt-dynamic.test:62:10: error: WARN3: expected string not found in input # WARN3: error: '[[FILE]]': Invalid data was encountered while parsing the file ^ <stdin>:2:1: note: scanning from here /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/tools/llvm-readobj/ELFDumper.cpp:1956:46: runtime error: addition of unsigned offset to 0x0000020c5b30 overflowed to 0x0000020c5b2f ^ <stdin>:2:1: note: with "FILE" equal to "/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/test/tools/llvm-readobj/ELF/Output/malformed-pt-dynamic\\.test\\.tmp3" /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/tools/llvm-readobj/ELFDumper.cpp:1956:46: runtime error: addition of unsigned offset to 0x0000020c5b30 overflowed to 0x0000020c5b2f ^ <stdin>:2:117: note: possible intended match here /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/tools/llvm-readobj/ELFDumper.cpp:1956:46: runtime error: addition of unsigned offset to 0x0000020c5b30 overflowed to 0x0000020c5b2f ^ Input file: <stdin> Check file: /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/test/tools/llvm-readobj/ELF/malformed-pt-dynamic.test
This commit is contained in:
parent
fdacd25874
commit
e7c1ab412e
@ -51,74 +51,11 @@
|
||||
|
||||
# WARN2-NOHEADERS: warning: '[[FILE]]': PT_DYNAMIC segment offset (0x1119) + file size (0x10) exceeds the size of the file (0x1118)
|
||||
|
||||
## Case C: test we report a warning when the offset + the file size of the PT_DYNAMIC is so large a
|
||||
## value that it overflows the platform address size type.
|
||||
|
||||
# RUN: yaml2obj %s -DOFFSET=0xffffffffffffffff -o %t3
|
||||
# RUN: not llvm-readobj %t3 --dynamic-table 2>&1 | FileCheck -DFILE=%t3 %s --check-prefix=WARN3
|
||||
# RUN: not llvm-readelf %t3 --dynamic-table 2>&1 | FileCheck -DFILE=%t3 %s --check-prefix=WARN3
|
||||
|
||||
# WARN3: warning: '[[FILE]]': PT_DYNAMIC segment offset (0xffffffffffffffff) + file size (0x10) exceeds the size of the file (0x1130)
|
||||
# WARN3: error: '[[FILE]]': Invalid data was encountered while parsing the file
|
||||
|
||||
# RUN: yaml2obj %s -DNOHEADERS=true -DOFFSET=0xffffffffffffffff -o %t3.noheaders
|
||||
# RUN: llvm-readobj %t3.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t3.noheaders %s --check-prefix=WARN3-NOHEADERS
|
||||
# RUN: llvm-readelf %t3.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t3.noheaders %s --check-prefix=WARN3-NOHEADERS
|
||||
|
||||
# WARN3-NOHEADERS: warning: '[[FILE]]': PT_DYNAMIC segment offset (0xffffffffffffffff) + file size (0x10) exceeds the size of the file (0x1118)
|
||||
|
||||
# RUN: yaml2obj %s -DFILESIZE=0xffffffffffffffff -o %t4
|
||||
# RUN: llvm-readobj %t4 --dynamic-table 2>&1 | FileCheck -DFILE=%t4 %s --check-prefix=WARN4
|
||||
# RUN: llvm-readelf %t4 --dynamic-table 2>&1 | FileCheck -DFILE=%t4 %s --check-prefix=WARN4
|
||||
|
||||
# WARN4: warning: '[[FILE]]': PT_DYNAMIC segment offset (0x1000) + file size (0xffffffffffffffff) exceeds the size of the file (0x1130)
|
||||
|
||||
# RUN: yaml2obj %s -DNOHEADERS=true -DFILESIZE=0xffffffffffffffff -o %t4.noheaders
|
||||
# RUN: llvm-readobj %t4.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t4.noheaders %s --check-prefix=WARN4-NOHEADERS
|
||||
# RUN: llvm-readelf %t4.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t4.noheaders %s --check-prefix=WARN4-NOHEADERS
|
||||
|
||||
# WARN4-NOHEADERS: warning: '[[FILE]]': PT_DYNAMIC segment offset (0x1000) + file size (0xffffffffffffffff) exceeds the size of the file (0x1118)
|
||||
|
||||
## Case D: the same as "Case C", but for a 32-bit object.
|
||||
|
||||
# RUN: yaml2obj %s -DBITS=32 -DOFFSET=0xffffffff -o %t5
|
||||
# RUN: not llvm-readobj %t5 --dynamic-table 2>&1 | FileCheck -DFILE=%t5 %s --check-prefix=WARN5
|
||||
# RUN: not llvm-readelf %t5 --dynamic-table 2>&1 | FileCheck -DFILE=%t5 %s --check-prefix=WARN5
|
||||
|
||||
# WARN5: warning: '[[FILE]]': PT_DYNAMIC segment offset (0xffffffff) + file size (0x8) exceeds the size of the file (0x10c8)
|
||||
# WARN5: error: '[[FILE]]': Invalid data was encountered while parsing the file
|
||||
|
||||
# RUN: yaml2obj %s -DNOHEADERS=true -DBITS=32 -DOFFSET=0xffffffff -o %t5.noheaders
|
||||
# RUN: llvm-readobj %t5.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t5.noheaders %s --check-prefix=WARN5-NOHEADERS
|
||||
# RUN: llvm-readelf %t5.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t5.noheaders %s --check-prefix=WARN5-NOHEADERS
|
||||
|
||||
# WARN5-NOHEADERS: warning: '[[FILE]]': PT_DYNAMIC segment offset (0xffffffff) + file size (0x8) exceeds the size of the file (0x10ac)
|
||||
|
||||
# RUN: yaml2obj %s -DBITS=32 -DFILESIZE=0xffffffff -o %t6
|
||||
# RUN: llvm-readobj %t6 --dynamic-table 2>&1 | FileCheck -DFILE=%t6 %s --check-prefix=WARN6
|
||||
# RUN: llvm-readelf %t6 --dynamic-table 2>&1 | FileCheck -DFILE=%t6 %s --check-prefix=WARN6
|
||||
|
||||
# WARN6: warning: '[[FILE]]': PT_DYNAMIC segment offset (0x1000) + file size (0xffffffff) exceeds the size of the file (0x10c8)
|
||||
|
||||
# RUN: yaml2obj %s -DNOHEADERS=true -DBITS=32 -DFILESIZE=0xffffffff -o %t6.noheaders
|
||||
# RUN: llvm-readobj %t6.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t6.noheaders %s --check-prefix=WARN6-NOHEADERS
|
||||
# RUN: llvm-readelf %t6.noheaders --dynamic-table 2>&1 | \
|
||||
# RUN: FileCheck -DFILE=%t6.noheaders %s --check-prefix=WARN6-NOHEADERS
|
||||
|
||||
# WARN6-NOHEADERS: warning: '[[FILE]]': PT_DYNAMIC segment offset (0x1000) + file size (0xffffffff) exceeds the size of the file (0x10ac)
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS[[BITS=64]]
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_EXEC
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_EXEC
|
||||
Sections:
|
||||
- Name: .dynamic
|
||||
Type: SHT_DYNAMIC
|
||||
|
@ -1892,10 +1892,8 @@ ELFDumper<ELFT>::findDynamic(const ELFFile<ELFT> *Obj) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (DynamicPhdr && ((DynamicPhdr->p_offset + DynamicPhdr->p_filesz >
|
||||
ObjF->getMemoryBufferRef().getBufferSize()) ||
|
||||
(DynamicPhdr->p_offset + DynamicPhdr->p_filesz <
|
||||
DynamicPhdr->p_offset))) {
|
||||
if (DynamicPhdr && DynamicPhdr->p_offset + DynamicPhdr->p_filesz >
|
||||
ObjF->getMemoryBufferRef().getBufferSize()) {
|
||||
reportUniqueWarning(createError(
|
||||
"PT_DYNAMIC segment offset (0x" +
|
||||
Twine::utohexstr(DynamicPhdr->p_offset) + ") + file size (0x" +
|
||||
|
Loading…
x
Reference in New Issue
Block a user