From bc5c29a65f5326484b12384a519945df341aa557 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 27 Oct 2016 20:59:10 +0000 Subject: Another additional error check for invalid Mach-O files for the obsolete load commands. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again 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 the library code can’t operate on. So known obsolete load commands will cause a hard error. Also to make things clear I have added comments to the values and structures in Support/Mach-O.h and Support/MachO.def as to what is obsolete. As noted in a TODO in the code, there may need to be a non-default mode to allow some unknown values for well structured Mach-O files with things like unknown load load commands. So things like using an old lldb on a newer Mach-O file could still provide some limited functionality. llvm-svn: 285342 --- .../Object/Inputs/macho-invalid-fvmfile-obsolete | Bin 0 -> 44 bytes .../Object/Inputs/macho-invalid-ident-obsolete | Bin 0 -> 36 bytes .../Object/Inputs/macho-invalid-idfvmlib-obsolete | Bin 0 -> 48 bytes .../Inputs/macho-invalid-loadfvmlib-obsolete | Bin 0 -> 48 bytes .../Inputs/macho-invalid-prebind_cksum-obsolete | Bin 0 -> 40 bytes .../Inputs/macho-invalid-prebound_dylib-obsolete | Bin 0 -> 48 bytes .../Object/Inputs/macho-invalid-prepage-obsolete | Bin 0 -> 44 bytes .../Object/Inputs/macho-invalid-symseg-obsolete | Bin 0 -> 44 bytes llvm/test/Object/macho-invalid.test | 24 +++++++++++++++++++++ 9 files changed, 24 insertions(+) create mode 100644 llvm/test/Object/Inputs/macho-invalid-fvmfile-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-ident-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-idfvmlib-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-loadfvmlib-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-prebind_cksum-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-prebound_dylib-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-prepage-obsolete create mode 100644 llvm/test/Object/Inputs/macho-invalid-symseg-obsolete (limited to 'llvm/test') diff --git a/llvm/test/Object/Inputs/macho-invalid-fvmfile-obsolete b/llvm/test/Object/Inputs/macho-invalid-fvmfile-obsolete new file mode 100644 index 00000000000..10e0df5b544 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-fvmfile-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-ident-obsolete b/llvm/test/Object/Inputs/macho-invalid-ident-obsolete new file mode 100644 index 00000000000..74d61677d68 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-ident-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-idfvmlib-obsolete b/llvm/test/Object/Inputs/macho-invalid-idfvmlib-obsolete new file mode 100644 index 00000000000..bf83e5b4a53 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-idfvmlib-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-loadfvmlib-obsolete b/llvm/test/Object/Inputs/macho-invalid-loadfvmlib-obsolete new file mode 100644 index 00000000000..bac12a2e5f4 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-loadfvmlib-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-prebind_cksum-obsolete b/llvm/test/Object/Inputs/macho-invalid-prebind_cksum-obsolete new file mode 100644 index 00000000000..6fa90d030a5 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-prebind_cksum-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-prebound_dylib-obsolete b/llvm/test/Object/Inputs/macho-invalid-prebound_dylib-obsolete new file mode 100644 index 00000000000..04d9f82bf3e Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-prebound_dylib-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-prepage-obsolete b/llvm/test/Object/Inputs/macho-invalid-prepage-obsolete new file mode 100644 index 00000000000..cfd6bae900e Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-prepage-obsolete differ diff --git a/llvm/test/Object/Inputs/macho-invalid-symseg-obsolete b/llvm/test/Object/Inputs/macho-invalid-symseg-obsolete new file mode 100644 index 00000000000..6330997e409 Binary files /dev/null and b/llvm/test/Object/Inputs/macho-invalid-symseg-obsolete differ diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test index 897b28e4a0f..f95eebc315a 100644 --- a/llvm/test/Object/macho-invalid.test +++ b/llvm/test/Object/macho-invalid.test @@ -409,3 +409,27 @@ INVALID-TWOLEVELHINTS-OFFSET-HNINTS: macho-invalid-twolevelhints-offset-nhints': RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-fat_cputype 2>&1 | FileCheck -check-prefix INVALID-FAT-CPUTYPE %s INVALID-FAT-CPUTYPE: macho-invalid-fat_cputype': truncated or malformed object (universal header architecture: 0's cputype does not match object file's mach header) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-prebind_cksum-obsolete 2>&1 | FileCheck -check-prefix INVALID-PREBIND_CKSUM-OBSOLETE %s +INVALID-PREBIND_CKSUM-OBSOLETE: macho-invalid-prebind_cksum-obsolete': truncated or malformed object (load command 0 for cmd value of: 23 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-symseg-obsolete 2>&1 | FileCheck -check-prefix INVALID-SYMSEG-OBSOLETE %s +INVALID-SYMSEG-OBSOLETE: macho-invalid-symseg-obsolete': truncated or malformed object (load command 0 for cmd value of: 3 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-idfvmlib-obsolete 2>&1 | FileCheck -check-prefix INVALID-IDFVMLIB-OBSOLETE %s +INVALID-IDFVMLIB-OBSOLETE: macho-invalid-idfvmlib-obsolete': truncated or malformed object (load command 0 for cmd value of: 7 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-loadfvmlib-obsolete 2>&1 | FileCheck -check-prefix INVALID-LOADFVMLIB-OBSOLETE %s +INVALID-LOADFVMLIB-OBSOLETE: macho-invalid-loadfvmlib-obsolete': truncated or malformed object (load command 0 for cmd value of: 6 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-prebound_dylib-obsolete 2>&1 | FileCheck -check-prefix INVALID-PREBOUND_DYLIB-OBSOLETE %s +INVALID-PREBOUND_DYLIB-OBSOLETE: macho-invalid-prebound_dylib-obsolete': truncated or malformed object (load command 0 for cmd value of: 16 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-ident-obsolete 2>&1 | FileCheck -check-prefix INVALID-IDENT-OBSOLETE %s +INVALID-IDENT-OBSOLETE: macho-invalid-ident-obsolete': truncated or malformed object (load command 0 for cmd value of: 8 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-fvmfile-obsolete 2>&1 | FileCheck -check-prefix INVALID-FVMFILE-OBSOLETE %s +INVALID-FVMFILE-OBSOLETE: macho-invalid-fvmfile-obsolete': truncated or malformed object (load command 0 for cmd value of: 9 is obsolete and not supported) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-prepage-obsolete 2>&1 | FileCheck -check-prefix INVALID-PREPAGE-OBSOLETE %s +INVALID-PREPAGE-OBSOLETE: macho-invalid-prepage-obsolete': truncated or malformed object (load command 0 for cmd value of: 10 is obsolete and not supported) -- cgit v1.2.3