diff options
| author | Kevin Enderby <enderby@apple.com> | 2016-10-19 23:44:34 +0000 |
|---|---|---|
| committer | Kevin Enderby <enderby@apple.com> | 2016-10-19 23:44:34 +0000 |
| commit | 210030ba95df715ec32d1dd2918f2ef8206817f7 (patch) | |
| tree | 7b8dfafbe3c6164e325dcd70e0110c007c4bd55a /llvm/test/Object | |
| parent | 6432d45f7b97e37535e62ab3b505d327c99ed74c (diff) | |
| download | bcm5719-llvm-210030ba95df715ec32d1dd2918f2ef8206817f7.tar.gz bcm5719-llvm-210030ba95df715ec32d1dd2918f2ef8206817f7.zip | |
Next set of additional error checks for invalid Mach-O files for the
load commands that use the MachO::thread_command type
but are not used in llvm libObject code but used in llvm tool code.
This includes the LC_UNIXTHREAD and LC_THREAD
load commands.
A quick note about the philosophy of the error checking in
libObject for Mach-O files, the idea behind the checking is
that we never will return a Mach-O file out of libObject that
contains unknown things in the load commands.
To do this the 32-bit ARM and PPC general tread states
needed to be defined as two test case binaries contained
them. If other thread states for other CPUs need to be
added we will do that as needed.
Going forward the LC_MAIN load command is used to
set the entry point in Mach-O executables these days
instead of an LC_UNIXTHREAD as was done in the past.
So today only in core files are LC_THREAD load commands
and thread states usually found.
Other thread states have not yet been defined in
include/Support/MachO.h at this time. But that can be
added as needed with their corresponding checking also
added.
llvm-svn: 284668
Diffstat (limited to 'llvm/test/Object')
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-thread-count-pastend | bin | 0 -> 40 bytes | |||
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-thread-count-wrong | bin | 0 -> 48 bytes | |||
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-thread-flavor-unknown | bin | 0 -> 48 bytes | |||
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-thread-state-pastend | bin | 0 -> 48 bytes | |||
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-thread-unknown-cputype | bin | 0 -> 48 bytes | |||
| -rw-r--r-- | llvm/test/Object/Inputs/macho-invalid-unixthread-more-than-one | bin | 0 -> 396 bytes | |||
| -rw-r--r-- | llvm/test/Object/macho-invalid.test | 18 |
7 files changed, 18 insertions, 0 deletions
diff --git a/llvm/test/Object/Inputs/macho-invalid-thread-count-pastend b/llvm/test/Object/Inputs/macho-invalid-thread-count-pastend Binary files differnew file mode 100644 index 00000000000..4511c04adfc --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-thread-count-pastend diff --git a/llvm/test/Object/Inputs/macho-invalid-thread-count-wrong b/llvm/test/Object/Inputs/macho-invalid-thread-count-wrong Binary files differnew file mode 100644 index 00000000000..8a96b9ddfc9 --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-thread-count-wrong diff --git a/llvm/test/Object/Inputs/macho-invalid-thread-flavor-unknown b/llvm/test/Object/Inputs/macho-invalid-thread-flavor-unknown Binary files differnew file mode 100644 index 00000000000..72a680c39bf --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-thread-flavor-unknown diff --git a/llvm/test/Object/Inputs/macho-invalid-thread-state-pastend b/llvm/test/Object/Inputs/macho-invalid-thread-state-pastend Binary files differnew file mode 100644 index 00000000000..051390f24b6 --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-thread-state-pastend diff --git a/llvm/test/Object/Inputs/macho-invalid-thread-unknown-cputype b/llvm/test/Object/Inputs/macho-invalid-thread-unknown-cputype Binary files differnew file mode 100644 index 00000000000..15dae3ed8e3 --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-thread-unknown-cputype diff --git a/llvm/test/Object/Inputs/macho-invalid-unixthread-more-than-one b/llvm/test/Object/Inputs/macho-invalid-unixthread-more-than-one Binary files differnew file mode 100644 index 00000000000..7ce66599bb9 --- /dev/null +++ b/llvm/test/Object/Inputs/macho-invalid-unixthread-more-than-one diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test index cde45206823..111ba661c93 100644 --- a/llvm/test/Object/macho-invalid.test +++ b/llvm/test/Object/macho-invalid.test @@ -376,3 +376,21 @@ INVALID-ROUTINES64-MORE-THAN-ONE: macho-invalid-routines64-more-than-one': trunc RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-codesign-bad-size 2>&1 | FileCheck -check-prefix INVALID-CODESIGN-BAD-SIZE %s INVALID-CODESIGN-BAD-SIZE: macho-invalid-codesign-bad-size': truncated or malformed object (LC_CODE_SIGNATURE command 0 has incorrect cmdsize) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-thread-count-pastend 2>&1 | FileCheck -check-prefix INVALID-THREAD-COUNT-PASTEND %s +INVALID-THREAD-COUNT-PASTEND: macho-invalid-thread-count-pastend': truncated or malformed object (load command 0 count in LC_UNIXTHREAD extends past end of command) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-thread-count-wrong 2>&1 | FileCheck -check-prefix INVALID-THREAD-COUNT-WRONG %s +INVALID-THREAD-COUNT-WRONG: macho-invalid-thread-count-wrong': truncated or malformed object (load command 0 count not x86_THREAD_STATE64_COUNT for flavor number 0 which is a x86_THREAD_STATE64 flavor in LC_THREAD command) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-thread-flavor-unknown 2>&1 | FileCheck -check-prefix INVALID-THREAD-FLAVOR-UNKNOWN %s +INVALID-THREAD-FLAVOR-UNKNOWN: macho-invalid-thread-flavor-unknown': truncated or malformed object (load command 0 unknown flavor (507) for flavor number 0 in LC_THREAD command) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-thread-state-pastend 2>&1 | FileCheck -check-prefix INVALID-THREAD-PASTEND %s +INVALID-THREAD-PASTEND: macho-invalid-thread-state-pastend': truncated or malformed object (load command 0 x86_THREAD_STATE64 extends past end of command in LC_THREAD command) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-thread-unknown-cputype 2>&1 | FileCheck -check-prefix INVALID-THREAD-UNKNOWN-CPUTYPE %s +INVALID-THREAD-UNKNOWN-CPUTYPE: macho-invalid-thread-unknown-cputype': truncated or malformed object (unknown cputype (328) load command 0 for LC_THREAD command can't be checked) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-unixthread-more-than-one 2>&1 | FileCheck -check-prefix INVALID-UNIXTHREAD-MORE-THAN-ONE %s +INVALID-UNIXTHREAD-MORE-THAN-ONE: macho-invalid-unixthread-more-than-one': truncated or malformed object (more than one LC_UNIXTHREAD command) |

