diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-07-02 12:58:37 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-07-02 12:58:37 +0000 |
commit | 234f5f675e7d48b8b23ca2a38f9f60d4ab9ef340 (patch) | |
tree | f2432dda34d0525ee17e82ba3dcd71a8565c7ee9 | |
parent | 0bde7c65275ef4fcd51bc92e1b6c280f9888b73f (diff) | |
download | bcm5719-llvm-234f5f675e7d48b8b23ca2a38f9f60d4ab9ef340.tar.gz bcm5719-llvm-234f5f675e7d48b8b23ca2a38f9f60d4ab9ef340.zip |
[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
llvm-svn: 364916
-rwxr-xr-x | llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 | bin | 1688 -> 0 bytes | |||
-rwxr-xr-x | llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 | bin | 1736 -> 0 bytes | |||
-rwxr-xr-x | llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 | bin | 1688 -> 0 bytes | |||
-rwxr-xr-x | llvm/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 | bin | 1720 -> 0 bytes | |||
-rw-r--r-- | llvm/test/Object/Inputs/corrupt-version.elf-x86_64 | bin | 5200 -> 0 bytes | |||
-rw-r--r-- | llvm/test/Object/Inputs/corrupt.elf-x86-64 | bin | 1024 -> 0 bytes | |||
-rw-r--r-- | llvm/test/Object/corrupt.test | 65 | ||||
-rw-r--r-- | llvm/test/Object/invalid.test | 197 |
8 files changed, 197 insertions, 65 deletions
diff --git a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 b/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 Binary files differdeleted file mode 100755 index d164d8243d5..00000000000 --- a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-offset.elf.x86-64 +++ /dev/null diff --git a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 b/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 Binary files differdeleted file mode 100755 index 2eed83cfc37..00000000000 --- a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-size.elf.x86-64 +++ /dev/null diff --git a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 b/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 Binary files differdeleted file mode 100755 index 122194ae6f0..00000000000 --- a/llvm/test/Object/Inputs/corrupt-invalid-dynamic-table-too-large.elf.x86-64 +++ /dev/null diff --git a/llvm/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 b/llvm/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 Binary files differdeleted file mode 100755 index 58d995933ec..00000000000 --- a/llvm/test/Object/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 +++ /dev/null diff --git a/llvm/test/Object/Inputs/corrupt-version.elf-x86_64 b/llvm/test/Object/Inputs/corrupt-version.elf-x86_64 Binary files differdeleted file mode 100644 index 1241a27a7bb..00000000000 --- a/llvm/test/Object/Inputs/corrupt-version.elf-x86_64 +++ /dev/null diff --git a/llvm/test/Object/Inputs/corrupt.elf-x86-64 b/llvm/test/Object/Inputs/corrupt.elf-x86-64 Binary files differdeleted file mode 100644 index 8ae5f175974..00000000000 --- a/llvm/test/Object/Inputs/corrupt.elf-x86-64 +++ /dev/null diff --git a/llvm/test/Object/corrupt.test b/llvm/test/Object/corrupt.test deleted file mode 100644 index 6953768c47d..00000000000 --- a/llvm/test/Object/corrupt.test +++ /dev/null @@ -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 diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index 102a5fcee57..725859dfeb3 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -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 |