xref: /aosp_15_r20/external/llvm/test/Object/macho-invalid.test (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// An odd Mach-O file, with just a mach header with all but the magic field
2*9880d681SAndroid Build Coastguard Worker// and filetype zeros. The cputype and cpusubtype fields being zero are invalid,
3*9880d681SAndroid Build Coastguard Worker// but that does not mater for the most part to display some of the contents.
4*9880d681SAndroid Build Coastguard WorkerRUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds -macho \
5*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix ZERO-NCMDS %s
6*9880d681SAndroid Build Coastguard WorkerZERO-NCMDS: MH_MAGIC_64 0 0 0x00 OBJECT 0 0 0x00000000
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-load-command 2>&1 \
9*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INCOMPLETE-LOADC %s
10*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-LOADC: truncated or malformed object (load command 0 extends past the end all load commands in the file)
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-load-command.1 2>&1 \
13*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INCOMPLETE-LOADC-1 %s
14*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-LOADC-1: truncated or malformed object (load command 1 extends past the end all load commands in the file)
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-too-small-load-command 2>&1 \
17*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix SMALL-LOADC-SIZE %s
18*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-too-small-load-command 2>&1 \
19*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix SMALL-LOADC-SIZE %s
20*9880d681SAndroid Build Coastguard WorkerSMALL-LOADC-SIZE: truncated or malformed object (load commands extend past the end of the file)
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-too-small-load-command.1 2>&1 \
23*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix SMALL-LOADC-SIZE-1 %s
24*9880d681SAndroid Build Coastguard WorkerSMALL-LOADC-SIZE-1: truncated or malformed object (load command 1 with size less than 8 bytes)
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command 2>&1 \
27*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix MULTIPLE-NOT-4 %s
28*9880d681SAndroid Build Coastguard WorkerMULTIPLE-NOT-4: truncated or malformed object (load command 0 cmdsize not a multiple of 4)
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-too-small-segment-load-command.1 2>&1 \
31*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix SMALL-SEGLOADC-SIZE %s
32*9880d681SAndroid Build Coastguard WorkerSMALL-SEGLOADC-SIZE: truncated or malformed object (load command 0 LC_SEGMENT cmdsize too small)
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-too-small-segment-load-command 2>&1 \
35*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix MULTIPLE-NOT-8 %s
36*9880d681SAndroid Build Coastguard WorkerMULTIPLE-NOT-8: truncated or malformed object (load command 0 cmdsize not a multiple of 8)
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-no-size-for-sections 2>&1 \
39*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix TOO-MANY-SECTS %s
40*9880d681SAndroid Build Coastguard WorkerTOO-MANY-SECTS: truncated or malformed object (load command 0 inconsistent cmdsize in LC_SEGMENT for the number of sections)
41*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-no-size-for-sections 2>&1 \
42*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix TOO-MANY-SECTS-64 %s
43*9880d681SAndroid Build Coastguard WorkerTOO-MANY-SECTS-64: truncated or malformed object (load command 0 inconsistent cmdsize in LC_SEGMENT_64 for the number of sections)
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -t %p/Inputs/macho-invalid-bad-symbol-index 2>&1 \
46*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix BAD-SYMBOL %s
47*9880d681SAndroid Build Coastguard WorkerBAD-SYMBOL: truncated or malformed object (ilocalsym plus nlocalsym in LC_DYSYMTAB load command extends past the end of the symbol table)
48*9880d681SAndroid Build Coastguard WorkerRUN: llvm-objdump -macho -t %p/Inputs/macho-valid-0-nsyms 2>&1 \
49*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix ZERO-NSYMS %s
50*9880d681SAndroid Build Coastguard WorkerZERO-NSYMS: SYMBOL TABLE
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -t %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
53*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF %s
54*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF: truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
55*9880d681SAndroid Build Coastguard WorkerRUN: llvm-nm -pa %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
56*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF-nm-pa %s
57*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF-nm-pa: 0000000000000000 - 00 0000    SO bad string index
58*9880d681SAndroid Build Coastguard WorkerRUN: llvm-nm -pax %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \
59*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF-nm-pax %s
60*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -t %p/Inputs/macho-bad-archive1.a 2>&1 \
63*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF-ARCHIVE %s
64*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF-ARCHIVE: macho-bad-archive1.a(macho-invalid-symbol-name-past-eof) truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-bad1.x86_64.i386 2>&1 \
67*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF-FAT %s
68*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF-FAT: macho-universal-bad1.x86_64.i386 (for architecture x86_64)  truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
69*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -arch all -t %p/Inputs/macho-universal-archive-bad1.x86_64.i386 2>&1 \
70*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix NAME-PAST-EOF-FAT-ARCHIVE %s
71*9880d681SAndroid Build Coastguard WorkerNAME-PAST-EOF-FAT-ARCHIVE: macho-universal-archive-bad1.x86_64.i386(macho-invalid-symbol-name-past-eof) (for architecture x86_64)  truncated or malformed object (bad string index: 4261412866 for symbol at index 0)
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard WorkerRUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
74*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s
75*9880d681SAndroid Build Coastguard WorkerINVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header
76*9880d681SAndroid Build Coastguard WorkerRUN: llvm-nm -m %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
77*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-m %s
78*9880d681SAndroid Build Coastguard WorkerINVALID-SECTION-IDX-SYMBOL-SEC-m: 0000000100000000 (?,?) [referenced dynamically] external __mh_execute_header
79*9880d681SAndroid Build Coastguard WorkerRUN: llvm-nm -pax %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
80*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-pax %s
81*9880d681SAndroid Build Coastguard WorkerINVALID-SECTION-IDX-SYMBOL-SEC-pax: 0000000100000000 0f 42 0010 00000065 __mh_execute_header
82*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -t %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \
83*9880d681SAndroid Build Coastguard WorkerRUN:      | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
84*9880d681SAndroid Build Coastguard WorkerINVALID-SECTION-IDX-SYMBOL-SEC-objdump: truncated or malformed object (bad section index: 66 for symbol at index 8)
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
87*9880d681SAndroid Build Coastguard WorkerINVALID-HEADER: The file was not recognized as a valid object file
88*9880d681SAndroid Build Coastguard Worker
89*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
90*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file)
91*9880d681SAndroid Build Coastguard Worker
92*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-bad-archive2.a 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-ARCHIVE %s
93*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-SEGMENT-LOADC-ARCHIVE: macho-bad-archive2.a(macho64-invalid-incomplete-segment-load-command) truncated or malformed object (load commands extend past the end of the file)
94*9880d681SAndroid Build Coastguard Worker
95*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT %s
96*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-SEGMENT-LOADC-FAT: macho-universal-bad2.x86_64.i386 (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file)
97*9880d681SAndroid Build Coastguard Worker
98*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-universal-archive-bad2.x86_64.i386 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE %s
99*9880d681SAndroid Build Coastguard WorkerINCOMPLETE-SEGMENT-LOADC-FAT-ARCHIVE: macho-universal-archive-bad2.x86_64.i386(macho64-invalid-incomplete-segment-load-command) (for architecture x86_64) truncated or malformed object (load commands extend past the end of the file)
100*9880d681SAndroid Build Coastguard Worker
101*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -universal-headers %p/Inputs/macho-invalid-fat 2>&1 | FileCheck -check-prefix INVALID-FAT %s
102*9880d681SAndroid Build Coastguard WorkerINVALID-FAT: truncated or malformed fat file (fat_arch_64 structs would extend past the end of the file)
103*9880d681SAndroid Build Coastguard Worker
104*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-objdump -macho -private-headers -arch all %p/Inputs/macho-invalid-fat.obj.elf-x86_64 2>&1 | FileCheck -check-prefix INVALID-FAT-ELF %s
105*9880d681SAndroid Build Coastguard WorkerINVALID-FAT-ELF: Mach-O universal file: {{.*}}/macho-invalid-fat.obj.elf-x86_64 for architecture x86_64 is not a Mach-O file or an archive file
106