summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2016-08-12 20:10:25 +0000
committerKevin Enderby <enderby@apple.com>2016-08-12 20:10:25 +0000
commitc614d283b7aecbc9bee0b7bdb7902d2796b04a8c (patch)
tree9f43e9ce045b19c270e196880462f8a502bbbcbe /llvm/test
parent17a907588ceb6c012fa3d92d5c68feb821f989a4 (diff)
downloadbcm5719-llvm-c614d283b7aecbc9bee0b7bdb7902d2796b04a8c.tar.gz
bcm5719-llvm-c614d283b7aecbc9bee0b7bdb7902d2796b04a8c.zip
Next set of additional error checks for invalid Mach-O files.
This contains the two missing checks for LC_SEGMENT load command fields. And checks for the Mach-O sections fields that would make them invalid. With the new checks, some of the existing malformed file checks now trips one of these instead of the issue it was having before so those tests were adjusted. llvm-svn: 278557
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-addrbin0 -> 162 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-addr-sizebin0 -> 163 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-offsetbin0 -> 152 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-offset-in-headersbin0 -> 152 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-offset-sizebin0 -> 152 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-reloffbin0 -> 152 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-reloff-nrelocsbin0 -> 152 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-section-size-filesizebin0 -> 163 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-segment-filesizebin0 -> 84 bytes
-rw-r--r--llvm/test/Object/Inputs/macho-invalid-segment-vmsizebin0 -> 84 bytes
-rw-r--r--llvm/test/Object/macho-invalid.test30
-rw-r--r--llvm/test/tools/llvm-objdump/X86/malformed-machos.test18
12 files changed, 39 insertions, 9 deletions
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-addr b/llvm/test/Object/Inputs/macho-invalid-section-addr
new file mode 100644
index 00000000000..c9a384a56f0
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-addr
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-addr-size b/llvm/test/Object/Inputs/macho-invalid-section-addr-size
new file mode 100644
index 00000000000..fdf8786ce94
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-addr-size
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-offset b/llvm/test/Object/Inputs/macho-invalid-section-offset
new file mode 100644
index 00000000000..4d30bf96e85
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-offset
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-offset-in-headers b/llvm/test/Object/Inputs/macho-invalid-section-offset-in-headers
new file mode 100644
index 00000000000..33161d3fc36
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-offset-in-headers
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-offset-size b/llvm/test/Object/Inputs/macho-invalid-section-offset-size
new file mode 100644
index 00000000000..747b1861ea2
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-offset-size
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-reloff b/llvm/test/Object/Inputs/macho-invalid-section-reloff
new file mode 100644
index 00000000000..2a46c51d975
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-reloff
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-reloff-nrelocs b/llvm/test/Object/Inputs/macho-invalid-section-reloff-nrelocs
new file mode 100644
index 00000000000..5b3fc9efb2c
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-reloff-nrelocs
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-section-size-filesize b/llvm/test/Object/Inputs/macho-invalid-section-size-filesize
new file mode 100644
index 00000000000..a5666d64e88
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-section-size-filesize
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-segment-filesize b/llvm/test/Object/Inputs/macho-invalid-segment-filesize
new file mode 100644
index 00000000000..e92cc51098b
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-segment-filesize
Binary files differ
diff --git a/llvm/test/Object/Inputs/macho-invalid-segment-vmsize b/llvm/test/Object/Inputs/macho-invalid-segment-vmsize
new file mode 100644
index 00000000000..a6715619234
--- /dev/null
+++ b/llvm/test/Object/Inputs/macho-invalid-segment-vmsize
Binary files differ
diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test
index 2236b0b03c1..91e1ea7b1a0 100644
--- a/llvm/test/Object/macho-invalid.test
+++ b/llvm/test/Object/macho-invalid.test
@@ -112,3 +112,33 @@ INVALID-SEGMENT-FILEOFF-NM: macho-invalid-segment-fileoff truncated or malformed
RUN: not llvm-size %p/Inputs/macho-invalid-segment-fileoff 2>&1 | FileCheck -check-prefix INVALID-SEGMENT-FILEOFF-SIZE %s
INVALID-SEGMENT-FILEOFF-SIZE: macho-invalid-segment-fileoff truncated or malformed object (load command 0 fileoff field in LC_SEGMENT extends past the end of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-segment-filesize 2>&1 | FileCheck -check-prefix INVALID-SEGMENT-FILESIZE %s
+INVALID-SEGMENT-FILESIZE: macho-invalid-segment-filesize': truncated or malformed object (load command 0 fileoff field plus filesize field in LC_SEGMENT extends past the end of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-segment-vmsize 2>&1 | FileCheck -check-prefix INVALID-SEGMENT-VMSIZE %s
+INVALID-SEGMENT-VMSIZE: macho-invalid-segment-vmsize': truncated or malformed object (load command 0 fileoff field in LC_SEGMENT greater than vmsize field)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-offset 2>&1 | FileCheck -check-prefix INVALID-SECTION-FILEOFF %s
+INVALID-SECTION-FILEOFF: macho-invalid-section-offset': truncated or malformed object (offset field of section 0 in LC_SEGMENT command 0 extends past the end of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-offset-in-headers 2>&1 | FileCheck -check-prefix INVALID-SECTION-FILEOFF-IN-HEADERS %s
+INVALID-SECTION-FILEOFF-IN-HEADERS: macho-invalid-section-offset-in-headers': truncated or malformed object (offset field of section 0 in LC_SEGMENT command 0 not past the headers of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-offset-size 2>&1 | FileCheck -check-prefix INVALID-SECTION-FILEOFF-SIZE %s
+INVALID-SECTION-FILEOFF-SIZE: macho-invalid-section-offset-size': truncated or malformed object (offset field plus size field of section 0 in LC_SEGMENT command 0 extends past the end of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-size-filesize 2>&1 | FileCheck -check-prefix INVALID-SECTION-SIZE-FILESIZE %s
+INVALID-SECTION-SIZE-FILESIZE: macho-invalid-section-size-filesize': truncated or malformed object (size field of section 0 in LC_SEGMENT command 0 greater than the segment)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-addr 2>&1 | FileCheck -check-prefix INVALID-SECTION-ADDR %s
+INVALID-SECTION-ADDR: macho-invalid-section-addr': truncated or malformed object (addr field of section 0 in LC_SEGMENT command 0 less than the segment's vmaddr)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-addr-size 2>&1 | FileCheck -check-prefix INVALID-SECTION-ADDR-SIZE %s
+INVALID-SECTION-ADDR-SIZE: macho-invalid-section-addr-size': truncated or malformed object (addr field plus size of section 0 in LC_SEGMENT command 0 greater than than the segment's vmaddr plus vmsize)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-reloff 2>&1 | FileCheck -check-prefix INVALID-SECTION-RELOFF %s
+INVALID-SECTION-RELOFF: macho-invalid-section-reloff': truncated or malformed object (reloff field of section 0 in LC_SEGMENT command 0 extends past the end of the file)
+
+RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-section-reloff-nrelocs 2>&1 | FileCheck -check-prefix INVALID-SECTION-RELOFF-NRELOCS %s
+INVALID-SECTION-RELOFF-NRELOCS: macho-invalid-section-reloff-nrelocs': truncated or malformed object (reloff field plus nreloc field times sizeof(struct relocation_info) of section 0 in LC_SEGMENT command 0 extends past the end of the file)
diff --git a/llvm/test/tools/llvm-objdump/X86/malformed-machos.test b/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
index a47e43443c5..9ada3ef0abe 100644
--- a/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
+++ b/llvm/test/tools/llvm-objdump/X86/malformed-machos.test
@@ -1,11 +1,11 @@
// These test checks that llvm-objdump will not crash with malformed Mach-O
// files. So the check line is not all that important but the bug fixes to
// make sure llvm-objdump is robust is what matters.
-# RUN: llvm-objdump -macho -objc-meta-data \
-# RUN: %p/Inputs/malformed-machos/mem-crup-0001.macho \
+# RUN: not llvm-objdump -macho -objc-meta-data \
+# RUN: %p/Inputs/malformed-machos/mem-crup-0001.macho 2>&1 \
# RUN: | FileCheck -check-prefix=m0001 %s
-# m0001: (method_t extends past the end of the section)
+# 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)
# RUN: llvm-objdump -macho -objc-meta-data \
# RUN: %p/Inputs/malformed-machos/mem-crup-0006.macho \
@@ -19,17 +19,17 @@
# m0010: 00000000000010e0 0x10e8 _OBJC_CLASS_
-# RUN: llvm-objdump -macho -objc-meta-data \
-# RUN: %p/Inputs/malformed-machos/mem-crup-0040.macho \
+# RUN: not llvm-objdump -macho -objc-meta-data \
+# RUN: %p/Inputs/malformed-machos/mem-crup-0040.macho 2>&1 \
# RUN: | FileCheck -check-prefix=m0040 %s
-# m0040: 00000000000010a0 0xf39 -[tiny_dylib init]
+# 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)
-# RUN: llvm-objdump -macho -objc-meta-data \
-# RUN: %p/Inputs/malformed-machos/mem-crup-0080.macho \
+# RUN: not llvm-objdump -macho -objc-meta-data \
+# RUN: %p/Inputs/malformed-machos/mem-crup-0080.macho 2>&1 \
# RUN: | FileCheck -check-prefix=m0080 %s
-# m0080: data 0xf960000 (struct class_ro_t *)
+# 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)
# RUN: llvm-objdump -macho -objc-meta-data \
# RUN: %p/Inputs/malformed-machos/mem-crup-0261.macho
OpenPOWER on IntegriCloud