summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objdump
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2017-03-20 19:46:55 +0000
committerKevin Enderby <enderby@apple.com>2017-03-20 19:46:55 +0000
commita8d256cb366d3a9d368e3bf962bab1e37b7f100c (patch)
tree877d1c3cd85656485e61f1d649aae9e4d8eb3b92 /llvm/test/tools/llvm-objdump
parent1aa0ed4e0d202fde2c7225aaae513b228cb9a2b3 (diff)
downloadbcm5719-llvm-a8d256cb366d3a9d368e3bf962bab1e37b7f100c.tar.gz
bcm5719-llvm-a8d256cb366d3a9d368e3bf962bab1e37b7f100c.zip
Add the rest of the error checking for Mach-O dyld compact bind entry errors
and test cases for each of the error checks. To do this more plumbing was needed so that the segment indexes and segment offsets can be checked. Basically what was done was the SegInfo from llvm-objdump’s MachODump.cpp was moved into libObject for Mach-O objects as BindRebaseSegInfo and it is only created when an iterator for bind or rebase entries are created. This commit really only adds the error checking and test cases for the bind table entires and the checking for the lazy bind and weak bind entries are still to be fully done as well as the rebase entires. Though some of the plumbing for those are added with this commit. Those other error checks and test cases will be added in follow on commits. Note, the two llvm_unreachable() calls should now actually be unreachable with the error checks in place and would take a logic bug in the error checking code to be reached if the segment indexes and segment offsets are used from a checked bind entry. Comments have been added to the methods that require the arguments to have been checked prior to calling. llvm-svn: 298292
Diffstat (limited to 'llvm/test/tools/llvm-objdump')
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-add-addr-imm-scaledbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-add_addr_ulebbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-bad-opcode-valuebin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-bind-add-addr-ulebbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-do-bind-no-segIndexbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-ulebbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-malformed-uleb128bin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-too-bigbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-special-immbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-seg-too-bigbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-segoff-too-bigbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-set-addend-slebbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-set-symbolbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-set-type-immbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-bind-uleb-times-skipping-ulebbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-dylib-ordinalbin0 -> 8456 bytes
-rwxr-xr-xllvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-symbolbin0 -> 8456 bytes
-rw-r--r--llvm/test/tools/llvm-objdump/X86/malformed-machos.test4
-rw-r--r--llvm/test/tools/llvm-objdump/macho-bad-bind.test50
19 files changed, 52 insertions, 2 deletions
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add-addr-imm-scaled b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add-addr-imm-scaled
new file mode 100755
index 00000000000..2180437408c
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add-addr-imm-scaled
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add_addr_uleb b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add_addr_uleb
new file mode 100755
index 00000000000..fc950db155a
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-add_addr_uleb
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bad-opcode-value b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bad-opcode-value
new file mode 100755
index 00000000000..c9195314c8e
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bad-opcode-value
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bind-add-addr-uleb b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bind-add-addr-uleb
new file mode 100755
index 00000000000..11abd6246b8
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-bind-add-addr-uleb
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-do-bind-no-segIndex b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-do-bind-no-segIndex
new file mode 100755
index 00000000000..cc4f09708c4
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-do-bind-no-segIndex
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb
new file mode 100755
index 00000000000..7769195d44c
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-malformed-uleb128 b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-malformed-uleb128
new file mode 100755
index 00000000000..0d5410e976e
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-malformed-uleb128
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-too-big b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-too-big
new file mode 100755
index 00000000000..40564b5a262
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-ordinal-uleb-too-big
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-special-imm b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-special-imm
new file mode 100755
index 00000000000..09bf10ded89
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-dylib-special-imm
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-seg-too-big b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-seg-too-big
new file mode 100755
index 00000000000..20be9957919
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-seg-too-big
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-segoff-too-big b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-segoff-too-big
new file mode 100755
index 00000000000..3f8e5ee8384
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-segoff-too-big
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-addend-sleb b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-addend-sleb
new file mode 100755
index 00000000000..726b96d3de3
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-addend-sleb
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-symbol b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-symbol
new file mode 100755
index 00000000000..b8201c3ad19
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-symbol
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-type-imm b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-type-imm
new file mode 100755
index 00000000000..002057e6b86
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-set-type-imm
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-bind-uleb-times-skipping-uleb b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-uleb-times-skipping-uleb
new file mode 100755
index 00000000000..81ab8130f66
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-bind-uleb-times-skipping-uleb
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-dylib-ordinal b/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-dylib-ordinal
new file mode 100755
index 00000000000..77daede7868
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-dylib-ordinal
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-symbol b/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-symbol
new file mode 100755
index 00000000000..0592b9bfe40
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/Inputs/macho-do-bind-no-symbol
Binary files differ
diff --git a/llvm/test/tools/llvm-objdump/X86/malformed-machos.test b/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
index 0a9ac02f0eb..292666a3725 100644
--- a/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
+++ b/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
@@ -64,5 +64,5 @@ INVALID-SYMBOL-STRX-UNIVERSAL: macho-invalid-symbol-strx-universal' (for archite
RUN: not llvm-objdump -macho -disassemble %p/Inputs/macho-invalid-symbol-lib_ordinal 2>&1 | FileCheck -check-prefix INVALID-SYMBOL-LIB_ORDINAL %s
INVALID-SYMBOL-LIB_ORDINAL: macho-invalid-symbol-lib_ordinal': truncated or malformed object (bad library ordinal: 7 for symbol at index 2)
-RUN: llvm-objdump -macho -objc-meta-data %p/Inputs/macho-invalid-bind-entry | FileCheck -check-prefix INVALID-BIND-ENTRY %s
-INVALID-BIND-ENTRY: 0000000100020c90 0x2d0409887202e473
+RUN: not llvm-objdump -macho -objc-meta-data %p/Inputs/macho-invalid-bind-entry 2>&1 | FileCheck -check-prefix INVALID-BIND-ENTRY %s
+INVALID-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)
diff --git a/llvm/test/tools/llvm-objdump/macho-bad-bind.test b/llvm/test/tools/llvm-objdump/macho-bad-bind.test
new file mode 100644
index 00000000000..dea86bb6514
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/macho-bad-bind.test
@@ -0,0 +1,50 @@
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-dylib-ordinal-uleb 2>&1 | FileCheck -check-prefix DYLIB-ORDINAL-ULEB %s
+DYLIB-ORDINAL-ULEB: macho-bind-dylib-ordinal-uleb': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB bad library ordinal: 355 (max 1) for opcode at: 0x0)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-dylib-ordinal-uleb-malformed-uleb128 2>&1 | FileCheck -check-prefix DYLIB-ORDINAL-ULEB-MALFORMED-ULEB128 %s
+DYLIB-ORDINAL-ULEB-MALFORMED-ULEB128: macho-bind-dylib-ordinal-uleb-malformed-uleb128': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB malformed uleb128, extends past end for opcode at: 0x0)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-dylib-ordinal-uleb-too-big 2>&1 | FileCheck -check-prefix DYLIB-ORDINAL-ULEB-TOO-BIG %s
+DYLIB-ORDINAL-ULEB-TOO-BIG: macho-bind-dylib-ordinal-uleb-too-big': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB uleb128 too big for uint64 for opcode at: 0x0)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-dylib-special-imm 2>&1 | FileCheck -check-prefix DYLIB-SPECIAL-IMM %s
+DYLIB-SPECIAL-IMM: macho-bind-dylib-special-imm': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_SPECIAL_IMM unknown special ordinal: -5 for opcode at: 0x0)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-set-symbol 2>&1 | FileCheck -check-prefix BIND-SET-SYMBOL %s
+BIND-SET-SYMBOL: macho-bind-set-symbol': truncated or malformed object (for BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM symbol name extends past opcodes for opcode at: 0x2)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-set-type-imm 2>&1 | FileCheck -check-prefix SET-TYPE-IMM %s
+SET-TYPE-IMM: macho-bind-set-type-imm': truncated or malformed object (for BIND_OPCODE_SET_TYPE_IMM bad bind type: 5 for opcode at: 0x14)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-set-addend-sleb 2>&1 | FileCheck -check-prefix SET-ADDEND-SLEB %s
+SET-ADDEND-SLEB: macho-bind-set-addend-sleb': truncated or malformed object (for BIND_OPCODE_SET_ADDEND_SLEB malformed sleb128, extends past end for opcode at: 0x14)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-seg-too-big 2>&1 | FileCheck -check-prefix SEG-TOO-BIG %s
+SEG-TOO-BIG: macho-bind-seg-too-big': truncated or malformed object (for BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB bad segIndex (too large) for opcode at: 0x15)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-segoff-too-big 2>&1 | FileCheck -check-prefix SEGOFF-TOO-BIG %s
+SEGOFF-TOO-BIG: macho-bind-segoff-too-big': truncated or malformed object (for BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB bad segOffset, too large for opcode at: 0x15)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-add_addr_uleb 2>&1 | FileCheck -check-prefix ADD_ADDR_ULEB %s
+ADD_ADDR_ULEB: macho-bind-add_addr_uleb': truncated or malformed object (for BIND_OPCODE_ADD_ADDR_ULEB bad segOffset, too large for opcode at: 0x17)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-do-bind-no-segIndex 2>&1 | FileCheck -check-prefix BIND-NO-SEGINDEX %s
+BIND-NO-SEGINDEX: macho-bind-do-bind-no-segIndex': truncated or malformed object (for BIND_OPCODE_DO_BIND missing preceding BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB for opcode at: 0x15)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-bind-add-addr-uleb 2>&1 | FileCheck -check-prefix ADD-ADDR-ULEB %s
+ADD-ADDR-ULEB: macho-bind-bind-add-addr-uleb': truncated or malformed object (for BIND_OPCODE_ADD_ADDR_ULEB (after adding ULEB) bad segOffset, too large for opcode at: 0x18)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-add-addr-imm-scaled 2>&1 | FileCheck -check-prefix ADD-ADDR-IMM-SCALED %s
+ADD-ADDR-IMM-SCALED: macho-bind-add-addr-imm-scaled': truncated or malformed object (for BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED (after adding immediate times the pointer size) bad segOffset, too large for opcode at: 0x17)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-uleb-times-skipping-uleb 2>&1 | FileCheck -check-prefix ULEB-TIMES-SKIPPING-ULEB %s
+ULEB-TIMES-SKIPPING-ULEB: macho-bind-uleb-times-skipping-uleb': truncated or malformed object (for BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB bad count and skip, too large for opcode at: 0x17)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-do-bind-no-symbol 2>&1 | FileCheck -check-prefix DO-BIND-NO-SYMBOL %s
+DO-BIND-NO-SYMBOL: macho-do-bind-no-symbol': truncated or malformed object (for BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB missing preceding BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM for opcode at: 0x5)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-do-bind-no-dylib-ordinal 2>&1 | FileCheck -check-prefix DO-BIND-NO-DYLIB-ORDINAL %s
+DO-BIND-NO-DYLIB-ORDINAL: macho-do-bind-no-dylib-ordinal': truncated or malformed object (for BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB missing preceding BIND_OPCODE_SET_DYLIB_ORDINAL_* for opcode at: 0x15)
+
+RUN: not llvm-objdump -macho -bind %p/Inputs/macho-bind-bad-opcode-value 2>&1 | FileCheck -check-prefix BAD-OPCODE-VALUE %s
+BAD-OPCODE-VALUE: macho-bind-bad-opcode-value': truncated or malformed object (bad bind info (bad opcode value 0xD0 for opcode at: 0x18)
OpenPOWER on IntegriCloud