diff --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h --- a/llvm/include/llvm/BinaryFormat/MachO.h +++ b/llvm/include/llvm/BinaryFormat/MachO.h @@ -1477,7 +1477,11 @@ CPU_SUBTYPE_ARM_V7EM = 16 }; -enum CPUSubTypeARM64 { CPU_SUBTYPE_ARM64_ALL = 0 }; +enum CPUSubTypeARM64 { + CPU_SUBTYPE_ARM64_ALL = 0, + CPU_SUBTYPE_ARM64_V8 = 1, + CPU_SUBTYPE_ARM64E = 2, +}; enum CPUSubTypeSPARC { CPU_SUBTYPE_SPARC_ALL = 0 }; diff --git a/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64e.macho.yaml b/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64e.macho.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64e.macho.yaml @@ -0,0 +1,11 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0100000C + cpusubtype: 0x00000002 + filetype: 0x00000001 + ncmds: 0 + sizeofcmds: 0 + flags: 0x00000000 + reserved: 0x00000000 +... diff --git a/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64v8.macho.yaml b/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64v8.macho.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/AArch64/Inputs/arm64v8.macho.yaml @@ -0,0 +1,11 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0100000C + cpusubtype: 0x00000001 + filetype: 0x00000001 + ncmds: 0 + sizeofcmds: 0 + flags: 0x00000000 + reserved: 0x00000000 +... diff --git a/llvm/test/tools/llvm-objdump/AArch64/macho-arm64-variants.test b/llvm/test/tools/llvm-objdump/AArch64/macho-arm64-variants.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/AArch64/macho-arm64-variants.test @@ -0,0 +1,12 @@ +// RUN: yaml2obj %p/Inputs/arm64v8.macho.yaml -o %tarm64v8.o +// RUN: llvm-objdump -p %tarm64v8.o | FileCheck -check-prefix=V8 -strict-whitespace %s +// RUN: yaml2obj %p/Inputs/arm64e.macho.yaml -o %tarm64e.o +// RUN: llvm-objdump -p %tarm64e.o | FileCheck -check-prefix=E -strict-whitespace %s + +V8: Mach header +V8-NEXT: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags +V8-NEXT: MH_MAGIC_64 ARM64 V8 0x00 OBJECT 0 0 0x00000000 + +E: Mach header +E-NEXT: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags +E-NEXT: MH_MAGIC_64 ARM64 E 0x00 OBJECT 0 0 0x00000000 diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -2031,6 +2031,14 @@ outs() << " cputype CPU_TYPE_ARM64\n"; outs() << " cpusubtype CPU_SUBTYPE_ARM64_ALL\n"; break; + case MachO::CPU_SUBTYPE_ARM64_V8: + outs() << " cputype CPU_TYPE_ARM64\n"; + outs() << " cpusubtype CPU_SUBTYPE_ARM64_V8\n"; + break; + case MachO::CPU_SUBTYPE_ARM64E: + outs() << " cputype CPU_TYPE_ARM64\n"; + outs() << " cpusubtype CPU_SUBTYPE_ARM64E\n"; + break; default: printUnknownCPUType(cputype, cpusubtype); break; @@ -8174,6 +8182,12 @@ case MachO::CPU_SUBTYPE_ARM64_ALL: outs() << " ALL"; break; + case MachO::CPU_SUBTYPE_ARM64_V8: + outs() << " V8"; + break; + case MachO::CPU_SUBTYPE_ARM64E: + outs() << " E"; + break; default: outs() << format(" %10d", cpusubtype & ~MachO::CPU_SUBTYPE_MASK); break; diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -162,6 +162,8 @@ static const EnumEntry MachOHeaderCpuSubtypesARM64[] = { LLVM_READOBJ_ENUM_ENT(MachO, CPU_SUBTYPE_ARM64_ALL), + LLVM_READOBJ_ENUM_ENT(MachO, CPU_SUBTYPE_ARM64_V8), + LLVM_READOBJ_ENUM_ENT(MachO, CPU_SUBTYPE_ARM64E), }; static const EnumEntry MachOHeaderCpuSubtypesSPARC[] = {