1// An odd Mach-O file, with just a mach header with all but the magic field
2// and filetype zeros. The cputype and cpusubtype fields being zero are invalid,
3// but that does not mater for the most part to display some of the contents.
4RUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds -macho \
5RUN:      | FileCheck -check-prefix ZERO-NCMDS %s
6ZERO-NCMDS: MH_MAGIC_64 0 0 0x00 OBJECT 0 0 0x00000000
7
8RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-load-command 2>&1 \
9RUN:      | FileCheck -check-prefix INCOMPLETE-LOADC %s
10INCOMPLETE-LOADC: Invalid data was encountered while parsing the file.
11
12RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-load-command 2>&1 \
13RUN:      | FileCheck -check-prefix SMALL-LOADC-SIZE %s
14RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-load-command 2>&1 \
15RUN:      | FileCheck -check-prefix SMALL-LOADC-SIZE %s
16SMALL-LOADC-SIZE: Mach-O load command with size < 8 bytes
17
18RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command 2>&1 \
19RUN:      | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s
20RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-segment-load-command 2>&1 \
21RUN:      | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s
22SMALL-SEGLOADC-SIZE: Mach-O segment load command size is too small
23
24RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-no-size-for-sections 2>&1 \
25RUN:      | FileCheck -check-prefix TOO-MANY-SECTS %s
26RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-no-size-for-sections 2>&1 \
27RUN:      | FileCheck -check-prefix TOO-MANY-SECTS %s
28TOO-MANY-SECTS: Mach-O segment load command contains too many sections
29
30RUN: not llvm-objdump -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \
31RUN:      | FileCheck -check-prefix BAD-SYMBOL %s
32BAD-SYMBOL: Invalid data was encountered while parsing the file.
33RUN: llvm-objdump -t %p/Inputs/macho-valid-0-nsyms 2>&1 \
34RUN:      | FileCheck -check-prefix ZERO-NSYMS %s
35ZERO-NSYMS: SYMBOL TABLE
36ZERO-NSYMS-NOT: Requested symbol index is out of range
37
38RUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
39RUN:      | FileCheck -check-prefix NAME-PAST-EOF %s
40NAME-PAST-EOF: error reading file: Invalid data was encountered while parsing the file.
41RUN: llvm-nm -pa %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
42RUN:      | FileCheck -check-prefix NAME-PAST-EOF-nm-pa %s
43NAME-PAST-EOF-nm-pa: 0000000000000000 - 00 0000    SO bad string index
44RUN: llvm-nm -pax %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
45RUN:      | FileCheck -check-prefix NAME-PAST-EOF-nm-pax %s
46NAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index
47
48RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
49RUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
50INVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header
51RUN: llvm-nm -m %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
52RUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-m %s
53INVALID-SECTION-IDX-SYMBOL-SEC-m: 0000000100000000 (?,?) [referenced dynamically] external __mh_execute_header
54RUN: llvm-nm -pax %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
55RUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-pax %s
56INVALID-SECTION-IDX-SYMBOL-SEC-pax: 0000000100000000 0f 42 0010 00000065 __mh_execute_header
57RUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
58RUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
59INVALID-SECTION-IDX-SYMBOL-SEC-objdump: Invalid data was encountered while parsing the file.
60
61RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
62INVALID-HEADER: The file was not recognized as a valid object file.
63NOT-INVALID-HEADER: Invalid data was encountered while parsing the file.
64
65RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
66INCOMPLETE-SEGMENT-LOADC: Invalid data was encountered while parsing the file
67