| Kevin Enderby | a59824a | 2015-10-06 22:27:08 +0000 | [diff] [blame] | 1 | // These test checks that llvm-objdump will not crash with malformed Mach-O |
| 2 | // files. So the check line is not all that important but the bug fixes to |
| 3 | // make sure llvm-objdump is robust is what matters. |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 4 | # RUN: not llvm-objdump -macho -objc-meta-data \ |
| 5 | # RUN: %p/Inputs/malformed-machos/mem-crup-0001.macho 2>&1 \ |
| Kevin Enderby | a59824a | 2015-10-06 22:27:08 +0000 | [diff] [blame] | 6 | # RUN: | FileCheck -check-prefix=m0001 %s |
| 7 | |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 8 | # m0001: mem-crup-0001.macho': truncated or malformed object (addr field plus size of section 2 in LC_SEGMENT_64 command 0 greater than than the segment's vmaddr plus vmsize) |
| Kevin Enderby | a59824a | 2015-10-06 22:27:08 +0000 | [diff] [blame] | 9 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 10 | # RUN: not llvm-objdump -macho -objc-meta-data \ |
| 11 | # RUN: %p/Inputs/malformed-machos/mem-crup-0006.macho 2>&1 \ |
| Kevin Enderby | a59824a | 2015-10-06 22:27:08 +0000 | [diff] [blame] | 12 | # RUN: | FileCheck -check-prefix=m0006 %s |
| 13 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 14 | # m0006: malformed-machos/mem-crup-0006.macho': truncated or malformed object (section contents at offset 4128 with a size of 176, overlaps section contents at offset 4128 with a size of 8) |
| Kevin Enderby | aac7538 | 2015-10-08 16:56:35 +0000 | [diff] [blame] | 15 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 16 | # RUN: not llvm-objdump -macho -objc-meta-data \ |
| 17 | # RUN: %p/Inputs/malformed-machos/mem-crup-0010.macho 2>&1 \ |
| Kevin Enderby | aac7538 | 2015-10-08 16:56:35 +0000 | [diff] [blame] | 18 | # RUN: | FileCheck -check-prefix=m0010 %s |
| 19 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 20 | # m0010: mem-crup-0010.macho': truncated or malformed object (section contents at offset 4320 with a size of 80, overlaps section contents at offset 4320 with a size of 8) |
| Kevin Enderby | 46e642f | 2015-10-08 22:50:55 +0000 | [diff] [blame] | 21 | |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 22 | # RUN: not llvm-objdump -macho -objc-meta-data \ |
| 23 | # RUN: %p/Inputs/malformed-machos/mem-crup-0040.macho 2>&1 \ |
| Kevin Enderby | 46e642f | 2015-10-08 22:50:55 +0000 | [diff] [blame] | 24 | # RUN: | FileCheck -check-prefix=m0040 %s |
| 25 | |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 26 | # m0040: mem-crup-0040.macho': truncated or malformed object (offset field plus size field of section 2 in LC_SEGMENT_64 command 1 extends past the end of the file) |
| Kevin Enderby | af7c9d0 | 2015-10-09 16:48:44 +0000 | [diff] [blame] | 27 | |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 28 | # RUN: not llvm-objdump -macho -objc-meta-data \ |
| 29 | # RUN: %p/Inputs/malformed-machos/mem-crup-0080.macho 2>&1 \ |
| Kevin Enderby | af7c9d0 | 2015-10-09 16:48:44 +0000 | [diff] [blame] | 30 | # RUN: | FileCheck -check-prefix=m0080 %s |
| 31 | |
| Kevin Enderby | c614d28 | 2016-08-12 20:10:25 +0000 | [diff] [blame] | 32 | # m0080: mem-crup-0080.macho': truncated or malformed object (addr field plus size of section 2 in LC_SEGMENT_64 command 1 greater than than the segment's vmaddr plus vmsize) |
| Kevin Enderby | af7c9d0 | 2015-10-09 16:48:44 +0000 | [diff] [blame] | 33 | |
| Colin LeMahieu | efe3732 | 2016-04-08 18:15:37 +0000 | [diff] [blame] | 34 | # RUN: llvm-objdump -macho -objc-meta-data \ |
| Kevin Enderby | d1c66dd | 2015-10-13 17:06:34 +0000 | [diff] [blame] | 35 | # RUN: %p/Inputs/malformed-machos/mem-crup-0261.macho |
| 36 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 37 | # RUN: not llvm-objdump -macho -disassemble \ |
| 38 | # RUN: %p/Inputs/malformed-machos/mem-crup-0337.macho 2>&1 \ |
| Kevin Enderby | d90a417 | 2015-10-10 00:05:01 +0000 | [diff] [blame] | 39 | # RUN: | FileCheck -check-prefix=m0337 %s |
| 40 | |
| Kevin Enderby | fbebe16 | 2016-11-02 21:08:39 +0000 | [diff] [blame] | 41 | # m0337: mem-crup-0337.macho': truncated or malformed object (section relocation entries at offset 0 with a size of 512, overlaps Mach-O headers at offset 0 with a size of 2048) |
| Kevin Enderby | 22fc007 | 2016-11-14 20:57:04 +0000 | [diff] [blame] | 42 | |
| 43 | RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-nsect 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-NSECT %s |
| 44 | INVALID-SYMBOL-NSECT: macho-invalid-symbol-nsect': truncated or malformed object (bad section index: 97 for symbol at index 1) |
| 45 | |
| Kevin Enderby | 844c4ac | 2016-11-15 23:07:41 +0000 | [diff] [blame^] | 46 | RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-nsect-archive 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-NSECT-ARCHIVE %s |
| 47 | INVALID-SYMBOL-NSECT-ARCHIVE: macho-invalid-symbol-nsect-archive(macho-invalid-symbol-nsect): truncated or malformed object (bad section index: 97 for symbol at index 1) |
| 48 | |
| Kevin Enderby | 22fc007 | 2016-11-14 20:57:04 +0000 | [diff] [blame] | 49 | RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-indr 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-INDR %s |
| 50 | INVALID-SYMBOL-INDR: macho-invalid-symbol-indr': truncated or malformed object (bad n_value: 22 past the end of string table, for N_INDR symbol at index 1) |
| 51 | |
| Kevin Enderby | 844c4ac | 2016-11-15 23:07:41 +0000 | [diff] [blame^] | 52 | RUN: not llvm-objdump -macho -disassemble -arch all %p/Inputs/macho-invalid-symbol-indr-archive-universal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-INDR-ARCHIVE-UNIVERSAL %s |
| 53 | INVALID-SYMBOL-INDR-ARCHIVE-UNIVERSAL: macho-invalid-symbol-indr-archive-universal(macho-invalid-symbol-indr) (for architecture i386): truncated or malformed object (bad n_value: 22 past the end of string table, for N_INDR symbol at index 1) |
| 54 | |
| Kevin Enderby | 22fc007 | 2016-11-14 20:57:04 +0000 | [diff] [blame] | 55 | RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-strx 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-STRX %s |
| 56 | INVALID-SYMBOL-STRX: macho-invalid-symbol-strx': truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1) |
| 57 | |
| Kevin Enderby | 844c4ac | 2016-11-15 23:07:41 +0000 | [diff] [blame^] | 58 | RUN: not llvm-objdump -macho -disassemble -arch all %p/Inputs/macho-invalid-symbol-strx-universal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-STRX-UNIVERSAL %s |
| 59 | INVALID-SYMBOL-STRX-UNIVERSAL: macho-invalid-symbol-strx-universal' (for architecture i386): truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1) |
| 60 | |
| Kevin Enderby | 22fc007 | 2016-11-14 20:57:04 +0000 | [diff] [blame] | 61 | RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-lib_ordinal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-LIB_ORDINAL %s |
| 62 | INVALID-SYMBOL-LIB_ORDINAL: macho-invalid-symbol-lib_ordinal': truncated or malformed object (bad library ordinal: 7 for symbol at index 2) |