mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 12:02:58 +02:00
8be76b0f42
load commands. The existing test case in test/Object/macho-invalid.test for macho-invalid-too-small-segment-load-command has a cmdsize of 55, while being too small also it is not a multiple of 4. So when that check is added this test case will produce a different error. So I constructed a new test case that will trigger the intended error. I also changed the error message to be consistent with the other malformed Mach-O file error messages which prints the load command index. I also removed both object_error::macho_load_segment_too_small and object_error::macho_load_segment_too_many_sections from Object/Error.h as they are not needed and can just use object_error::parse_failed and let the error message string distinguish the specific error. llvm-svn: 268652
77 lines
5.3 KiB
Plaintext
77 lines
5.3 KiB
Plaintext
// An odd Mach-O file, with just a mach header with all but the magic field
|
|
// and filetype zeros. The cputype and cpusubtype fields being zero are invalid,
|
|
// but that does not mater for the most part to display some of the contents.
|
|
RUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds -macho \
|
|
RUN: | FileCheck -check-prefix ZERO-NCMDS %s
|
|
ZERO-NCMDS: MH_MAGIC_64 0 0 0x00 OBJECT 0 0 0x00000000
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-load-command 2>&1 \
|
|
RUN: | FileCheck -check-prefix INCOMPLETE-LOADC %s
|
|
INCOMPLETE-LOADC: truncated or malformed object (load command 0 extends past the end all load commands in the file)
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-load-command.1 2>&1 \
|
|
RUN: | FileCheck -check-prefix INCOMPLETE-LOADC-1 %s
|
|
INCOMPLETE-LOADC-1: truncated or malformed object (load command 1 extends past the end all load commands in the file)
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-too-small-load-command 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE %s
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-too-small-load-command 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE %s
|
|
SMALL-LOADC-SIZE: truncated or malformed object (load commands extend past the end of the file)
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-too-small-load-command.1 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-LOADC-SIZE-1 %s
|
|
SMALL-LOADC-SIZE-1: truncated or malformed object (load command 1 with size less than 8 bytes)
|
|
|
|
RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s
|
|
RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command.1 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s
|
|
SMALL-SEGLOADC-SIZE: truncated or malformed object (load command 0 LC_SEGMENT cmdsize too small)
|
|
RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-segment-load-command 2>&1 \
|
|
RUN: | FileCheck -check-prefix SMALL-SEGLOADC-SIZE-64 %s
|
|
SMALL-SEGLOADC-SIZE-64: truncated or malformed object (load command 0 LC_SEGMENT_64 cmdsize too small)
|
|
|
|
RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-no-size-for-sections 2>&1 \
|
|
RUN: | FileCheck -check-prefix TOO-MANY-SECTS %s
|
|
TOO-MANY-SECTS: truncated or malformed object (load command 0 inconsistent cmdsize in LC_SEGMENT for the number of sections)
|
|
RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-no-size-for-sections 2>&1 \
|
|
RUN: | FileCheck -check-prefix TOO-MANY-SECTS-64 %s
|
|
TOO-MANY-SECTS-64: truncated or malformed object (load command 0 inconsistent cmdsize in LC_SEGMENT_64 for the number of sections)
|
|
|
|
RUN: not llvm-objdump -macho -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \
|
|
RUN: | FileCheck -check-prefix BAD-SYMBOL %s
|
|
BAD-SYMBOL: truncated or malformed object (ilocalsym plus nlocalsym in LC_DYSYMTAB load command extends past the end of the symbol table)
|
|
RUN: llvm-objdump -macho -t %p/Inputs/macho-valid-0-nsyms 2>&1 \
|
|
RUN: | FileCheck -check-prefix ZERO-NSYMS %s
|
|
ZERO-NSYMS: SYMBOL TABLE
|
|
|
|
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
|
|
RUN: | FileCheck -check-prefix NAME-PAST-EOF %s
|
|
NAME-PAST-EOF: truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
|
|
RUN: llvm-nm -pa %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
|
|
RUN: | FileCheck -check-prefix NAME-PAST-EOF-nm-pa %s
|
|
NAME-PAST-EOF-nm-pa: 0000000000000000 - 00 0000 SO bad string index
|
|
RUN: llvm-nm -pax %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
|
|
RUN: | FileCheck -check-prefix NAME-PAST-EOF-nm-pax %s
|
|
NAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index
|
|
|
|
RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
|
|
INVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header
|
|
RUN: llvm-nm -m %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-m %s
|
|
INVALID-SECTION-IDX-SYMBOL-SEC-m: 0000000100000000 (?,?) [referenced dynamically] external __mh_execute_header
|
|
RUN: llvm-nm -pax %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-pax %s
|
|
INVALID-SECTION-IDX-SYMBOL-SEC-pax: 0000000100000000 0f 42 0010 00000065 __mh_execute_header
|
|
RUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
|
|
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
|
|
INVALID-SECTION-IDX-SYMBOL-SEC-objdump: truncated or malformed object (bad section index: 66 for symbol at index 8)
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
|
|
INVALID-HEADER: The file was not recognized as a valid object file
|
|
|
|
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
|
|
INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file)
|