blob: 292666a37254c99afb893b22ebef189ada741886 [file] [log] [blame]
Kevin Enderbya59824a2015-10-06 22:27:08 +00001// 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 Enderbyc614d282016-08-12 20:10:25 +00004# RUN: not llvm-objdump -macho -objc-meta-data \
5# RUN: %p/Inputs/malformed-machos/mem-crup-0001.macho 2>&1 \
Kevin Enderbya59824a2015-10-06 22:27:08 +00006# RUN: | FileCheck -check-prefix=m0001 %s
7
Kevin Enderbyc614d282016-08-12 20:10:25 +00008# 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 Enderbya59824a2015-10-06 22:27:08 +00009
Kevin Enderbyfbebe162016-11-02 21:08:39 +000010# RUN: not llvm-objdump -macho -objc-meta-data \
11# RUN: %p/Inputs/malformed-machos/mem-crup-0006.macho 2>&1 \
Kevin Enderbya59824a2015-10-06 22:27:08 +000012# RUN: | FileCheck -check-prefix=m0006 %s
13
Kevin Enderbyfbebe162016-11-02 21:08:39 +000014# 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 Enderbyaac75382015-10-08 16:56:35 +000015
Kevin Enderbyfbebe162016-11-02 21:08:39 +000016# RUN: not llvm-objdump -macho -objc-meta-data \
17# RUN: %p/Inputs/malformed-machos/mem-crup-0010.macho 2>&1 \
Kevin Enderbyaac75382015-10-08 16:56:35 +000018# RUN: | FileCheck -check-prefix=m0010 %s
19
Kevin Enderbyfbebe162016-11-02 21:08:39 +000020# 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 Enderby46e642f2015-10-08 22:50:55 +000021
Kevin Enderbyc614d282016-08-12 20:10:25 +000022# RUN: not llvm-objdump -macho -objc-meta-data \
23# RUN: %p/Inputs/malformed-machos/mem-crup-0040.macho 2>&1 \
Kevin Enderby46e642f2015-10-08 22:50:55 +000024# RUN: | FileCheck -check-prefix=m0040 %s
25
Kevin Enderbyc614d282016-08-12 20:10:25 +000026# 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 Enderbyaf7c9d02015-10-09 16:48:44 +000027
Kevin Enderbyc614d282016-08-12 20:10:25 +000028# RUN: not llvm-objdump -macho -objc-meta-data \
29# RUN: %p/Inputs/malformed-machos/mem-crup-0080.macho 2>&1 \
Kevin Enderbyaf7c9d02015-10-09 16:48:44 +000030# RUN: | FileCheck -check-prefix=m0080 %s
31
Kevin Enderbyc614d282016-08-12 20:10:25 +000032# 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 Enderbyaf7c9d02015-10-09 16:48:44 +000033
Colin LeMahieuefe37322016-04-08 18:15:37 +000034# RUN: llvm-objdump -macho -objc-meta-data \
Kevin Enderbyd1c66dd2015-10-13 17:06:34 +000035# RUN: %p/Inputs/malformed-machos/mem-crup-0261.macho
36
Kevin Enderbyfbebe162016-11-02 21:08:39 +000037# RUN: not llvm-objdump -macho -disassemble \
38# RUN: %p/Inputs/malformed-machos/mem-crup-0337.macho 2>&1 \
Kevin Enderbyd90a4172015-10-10 00:05:01 +000039# RUN: | FileCheck -check-prefix=m0337 %s
40
Kevin Enderbyfbebe162016-11-02 21:08:39 +000041# 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 Enderby22fc0072016-11-14 20:57:04 +000042
43RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-nsect 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-NSECT %s
44INVALID-SYMBOL-NSECT: macho-invalid-symbol-nsect': truncated or malformed object (bad section index: 97 for symbol at index 1)
45
Kevin Enderby844c4ac2016-11-15 23:07:41 +000046RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-nsect-archive 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-NSECT-ARCHIVE %s
47INVALID-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 Enderby22fc0072016-11-14 20:57:04 +000049RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-indr 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-INDR %s
50INVALID-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 Enderby844c4ac2016-11-15 23:07:41 +000052RUN: 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
53INVALID-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 Enderby22fc0072016-11-14 20:57:04 +000055RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-strx 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-STRX %s
56INVALID-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 Enderby7fa40c92016-11-16 22:17:38 +000058RUN: not llvm-objdump -disassemble %p/Inputs/macho-invalid-symbol-strx 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-STRX-NO-MACHO-FLAG %s
59INVALID-SYMBOL-STRX-NO-MACHO-FLAG: macho-invalid-symbol-strx': truncated or malformed object (bad string index: 22 for symbol at index 1)
60
Kevin Enderby844c4ac2016-11-15 23:07:41 +000061RUN: not llvm-objdump -macho -disassemble -arch all %p/Inputs/macho-invalid-symbol-strx-universal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-STRX-UNIVERSAL %s
62INVALID-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)
63
Kevin Enderby22fc0072016-11-14 20:57:04 +000064RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-lib_ordinal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-LIB_ORDINAL %s
65INVALID-SYMBOL-LIB_ORDINAL: macho-invalid-symbol-lib_ordinal': truncated or malformed object (bad library ordinal: 7 for symbol at index 2)
Kevin Enderby6de201e2017-02-03 18:22:04 +000066
Kevin Enderbya8d256c2017-03-20 19:46:55 +000067RUN: not llvm-objdump -macho -objc-meta-data %p/Inputs/macho-invalid-bind-entry 2>&1 | FileCheck -check-prefix INVALID-BIND-ENTRY %s
68INVALID-BIND-ENTRY: macho-invalid-bind-entry': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB bad library ordinal: 83 (max 0) for opcode at: 0x0)