diff --git a/test/Object/macho-invalid.test b/test/Object/macho-invalid.test index 781c9367c1e..77a3944bdd6 100644 --- a/test/Object/macho-invalid.test +++ b/test/Object/macho-invalid.test @@ -1,5 +1,9 @@ -// No crash, might not be totally invalid -RUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds +// An odd Mach-O file, with just a mach header with all but the magic field +// and filetype zeros. The cputype and cpusubtype fields being zero are invalid, +// but that does not mater for the most part to display some of the contents. +RUN: llvm-objdump -private-headers %p/Inputs/macho-invalid-zero-ncmds -macho \ +RUN: | FileCheck -check-prefix ZERO-NCMDS %s +ZERO-NCMDS: MH_MAGIC_64 0 0 0x00 OBJECT 0 0 0x00000000 RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-load-command 2>&1 \ RUN: | FileCheck -check-prefix INCOMPLETE-LOADC %s diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 973db5985a6..318d8374731 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -6893,6 +6893,10 @@ static void PrintMachHeader(uint32_t magic, uint32_t cputype, break; } break; + default: + outs() << format(" %7d", cputype); + outs() << format(" %10d", cpusubtype & ~MachO::CPU_SUBTYPE_MASK); + break; } if ((cpusubtype & MachO::CPU_SUBTYPE_MASK) == MachO::CPU_SUBTYPE_LIB64) { outs() << " LIB64";