[llvm] r364916 - [Object/invalid.test] - Convert Object/corrupt.test to YAML and merge the result into invalid.test
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 05:58:37 PDT 2019
Author: grimar
Date: Tue Jul 2 05:58:37 2019
New Revision: 364916
URL: http://llvm.org/viewvc/llvm-project?rev=364916&view=rev
Log:
[Object/invalid.test] - Convert Object/corrupt.test to YAML and merge the result into invalid.test
Object/corrupt.test has the same purpose as Object/invalid.test:
it tests the behavior on invalid inputs.
In this patch I converted it to YAML, merged into invalid.test,
added comments and removed a few precompiled binaries.
Differential revision: https://reviews.llvm.org/D63927
Removed:
llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64
llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64
llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64
llvm/trunk/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64
llvm/trunk/test/Object/Inputs/corrupt-version.elf-x86_64
llvm/trunk/test/Object/Inputs/corrupt.elf-x86-64
llvm/trunk/test/Object/corrupt.test
Modified:
llvm/trunk/test/Object/invalid.test
Removed: llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 (original) and llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 (removed) differ
Removed: llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 (original) and llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 (removed) differ
Removed: llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 (original) and llvm/trunk/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 (removed) differ
Removed: llvm/trunk/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 (original) and llvm/trunk/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 (removed) differ
Removed: llvm/trunk/test/Object/Inputs/corrupt-version.elf-x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt-version.elf-x86_64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt-version.elf-x86_64 (original) and llvm/trunk/test/Object/Inputs/corrupt-version.elf-x86_64 (removed) differ
Removed: llvm/trunk/test/Object/Inputs/corrupt.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/corrupt.elf-x86-64?rev=364915&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/corrupt.elf-x86-64 (original) and llvm/trunk/test/Object/Inputs/corrupt.elf-x86-64 (removed) differ
Removed: llvm/trunk/test/Object/corrupt.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/corrupt.test?rev=364915&view=auto
==============================================================================
--- llvm/trunk/test/Object/corrupt.test (original)
+++ llvm/trunk/test/Object/corrupt.test (removed)
@@ -1,65 +0,0 @@
-// Section name offset overflows section name string table.
-RUN: not llvm-readobj %p/Inputs/corrupt.elf-x86-64 -sections \
-RUN: 2>&1 | FileCheck --check-prefix=SECNAME %s
-
-SECNAME: invalid string offset
-
-
-// Section data offset past end of file.
-RUN: not llvm-readobj %p/Inputs/corrupt.elf-x86-64 -sections -section-data \
-RUN: 2>&1 | FileCheck --check-prefix=SECDATA %s
-
-SECDATA: invalid section offset
-
-
-// Symbol name offset overflows string table.
-RUN: not llvm-readobj %p/Inputs/corrupt.elf-x86-64 -symbols \
-RUN: 2>&1 | FileCheck --check-prefix=SYMNAME %s
-
-SYMNAME: invalid string offset
-
-
-// Version index in .gnu.version overflows the version map.
-RUN: not llvm-readobj %p/Inputs/corrupt-version.elf-x86_64 -dt \
-RUN: 2>&1 | FileCheck --check-prefix=VER %s
-
-VER: error: Invalid version entry
-
-RUN: not llvm-readobj -l \
-RUN: %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=PHENTSIZE %s
-
-PHENTSIZE: invalid e_phentsize
-
-RUN: llvm-readobj --dynamic-table \
-RUN: %p/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=VIRTADDR %s
-
-VIRTADDR: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment
-
-
-RUN: not llvm-readobj --dyn-relocations \
-RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=RELOC %s
-
-RELOC: Invalid entity size
-
-RUN: not llvm-readobj --dyn-relocations \
-RUN: %p/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=DYN-TABLE-SIZE %s
-
-DYN-TABLE-SIZE: Invalid entity size
-
-
-RUN: not llvm-readobj --dyn-relocations \
-RUN: %p/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=DYN-TABLE-OFFSET %s
-
-DYN-TABLE-OFFSET: error: PT_DYNAMIC segment offset + size exceeds the size of the file
-
-
-RUN: not llvm-readobj --dyn-relocations \
-RUN: %p/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 2>&1 | \
-RUN: FileCheck --check-prefix=DYN-TABLE-TOO-LARGE %s
-
-DYN-TABLE-TOO-LARGE: error: PT_DYNAMIC segment offset + size exceeds the size of the file
Modified: llvm/trunk/test/Object/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/invalid.test?rev=364916&r1=364915&r2=364916&view=diff
==============================================================================
--- llvm/trunk/test/Object/invalid.test (original)
+++ llvm/trunk/test/Object/invalid.test Tue Jul 2 05:58:37 2019
@@ -339,3 +339,200 @@ Sections:
# RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s
# COFF-HEADER: The file was not recognized as a valid object file
+
+## Check that llvm-readobj reports an error if section name offset
+## overflows the section name string table.
+
+# RUN: yaml2obj %s --docnum=17 -o %t17
+# RUN: not llvm-readobj --sections %t17 2>&1 | FileCheck --check-prefix=BROKEN-SECNAME %s
+
+## BROKEN-SECNAME: invalid string offset
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .shstrtab
+ Type: SHT_STRTAB
+ Size: 1
+
+## Check that llvm-readobj reports an error if a section has a broken offset
+## that goes past the end of the file.
+
+# RUN: yaml2obj %s --docnum=18 -o %t18
+# RUN: not llvm-readobj --sections --section-data %t18 2>&1 \
+# RUN: | FileCheck --check-prefix=BROKEN-SECSHOFFSET %s
+
+# BROKEN-SECSHOFFSET: invalid section offset
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .foo
+ Type: SHT_PROGBITS
+ ShOffset: 0xFFFF0000
+
+## Check that llvm-readobj reports an error if symbol name
+## offset goes past the end of the symbol string table.
+
+# RUN: yaml2obj %s --docnum=19 -o %t19
+# RUN: not llvm-readobj --symbols %t19 2>&1 | FileCheck --check-prefix=INVALID-SYM-NAME %s
+
+# INVALID-SYM-NAME: error: Invalid data was encountered while parsing the file
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .strtab
+ Type: SHT_STRTAB
+ Size: 1
+Symbols:
+ - Name: foo
+
+## Version index in .gnu.version overflows the version map.
+## Check llvm-readobj reports it.
+
+# RUN: yaml2obj %s --docnum=20 -o %t20
+# RUN: not llvm-readobj -dt %t20 2>&1 | FileCheck --check-prefix=INVALID-VERSION %s
+
+# INVALID-VERSION: error: Invalid version entry
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .gnu.version
+ Type: SHT_GNU_versym
+ Entries: [ 0xFF ]
+DynamicSymbols:
+ - Name: foo
+
+## ELF header contains e_phentsize field with a value != sizeof(Elf_Phdr).
+## Check llvm-readobj reports it.
+
+# RUN: not llvm-readobj -l %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 \
+# RUN: | FileCheck --check-prefix=PHENTSIZE %s
+
+# PHENTSIZE: invalid e_phentsize
+
+## The dynamic table contains DT_STRTAB with a value that is not in any loadable segment.
+## Check llvm-readobj reports it.
+
+# RUN: yaml2obj %s --docnum=21 -o %t21
+# RUN: llvm-readobj --dynamic-table %t21 2>&1 | FileCheck --check-prefix=INVALID-DTSTRTAB %s
+
+# INVALID-DTSTRTAB: warning: Unable to parse DT_STRTAB: Virtual address is not in any segment
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ Entries:
+ - Tag: DT_STRTAB
+ Value: 0xFFFF0000
+ - Tag: DT_NULL
+ Value: 0x0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+
+## Check that llvm-readobj reports an error when a dynamic relocation section
+## has sh_entsize field with size != sizeof(Elf_Rela).
+
+# RUN: not llvm-readobj --dyn-relocations \
+# RUN: %p/Inputs/corrupt-invalid-relocation-size.elf.x86-64 2>&1 \
+# RUN: | FileCheck --check-prefix=RELOC-BROKEN-ENTSIZE %s
+
+# RELOC-BROKEN-ENTSIZE: Invalid entity size
+
+## Check that llvm-readobj reports an error when .dynamic section has an invalid
+## size, which isn't a multiple of the dynamic entry size.
+
+# RUN: yaml2obj %s --docnum=22 -o %t22
+# RUN: not llvm-readobj --dyn-relocations %t22 2>&1 | FileCheck --check-prefix=DYN-TABLE-SIZE %s
+
+# DYN-TABLE-SIZE: Invalid entity size
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Content: "00"
+
+## PT_DYNAMIC's p_offset field is so large that p_offset + p_filesz is larger
+## 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
+
+# DYN-TABLE-PHDR: error: PT_DYNAMIC segment offset + size exceeds the size of the file
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Entries:
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_DYNAMIC
+ Offset: 0xffff0000
+ Sections:
+ - Section: .dynamic
+
+## PT_DYNAMIC's p_filesz field is so large that p_offset + p_filesz is larger
+## 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: | FileCheck --check-prefix=DYN-TABLE-PHDR %s
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Entries:
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_DYNAMIC
+ FileSize: 0xffff0000
+ Sections:
+ - Section: .dynamic
More information about the llvm-commits
mailing list