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 @@ -1492,6 +1492,7 @@ enum CPUSubTypeARM64 { CPU_SUBTYPE_ARM64_ALL = 0, + CPU_SUBTYPE_ARM64_V8 = 1, CPU_SUBTYPE_ARM64E = 2, }; diff --git a/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-arm64-v8.test b/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-arm64-v8.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-arm64-v8.test @@ -0,0 +1,18 @@ +# RUN: yaml2obj %s -o %tarm-v8.o +# RUN: llvm-objdump -p %tarm-v8.o | FileCheck --strict-whitespace %s + +# CHECK: Mach header +# CHECK-NEXT: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags +# CHECK-NEXT: MH_MAGIC_64 ARM64 V8 0x00 OBJECT 0 0 0x00000000 + +--- !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-readobj/MachO/file-headers-arm64.test b/llvm/test/tools/llvm-readobj/MachO/file-headers-arm64.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/MachO/file-headers-arm64.test @@ -0,0 +1,77 @@ +## Check subtype Arm64-ALL: +# RUN: yaml2obj %s -o %t.arm -DSUBTYPE=0x0 +# RUN: llvm-readobj -h %t.arm \ +# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.arm --check-prefix=ARM64-ALL + +# ARM64-ALL:File: [[FILE]] +# ARM64-ALL-NEXT:Format: Mach-O arm64 +# ARM64-ALL-NEXT:Arch: aarch64 +# ARM64-ALL-NEXT:AddressSize: 64bit +# ARM64-ALL-NEXT:MachHeader { +# ARM64-ALL-NEXT: Magic: Magic64 (0xFEEDFACF) +# ARM64-ALL-NEXT: CpuType: Arm64 (0x100000C) +# ARM64-ALL-NEXT: CpuSubType: CPU_SUBTYPE_ARM64_ALL (0x0) +# ARM64-ALL-NEXT: FileType: Relocatable (0x1) +# ARM64-ALL-NEXT: NumOfLoadCommands: 0 +# ARM64-ALL-NEXT: SizeOfLoadCommands: 0 +# ARM64-ALL-NEXT: Flags [ (0x0) +# ARM64-ALL-NEXT: ] +# ARM64-ALL-NEXT: Reserved: 0x0 +# ARM64-ALL-NEXT:} +# ARM64-ALL-NOT:{{.}} + +## Check subtype Arm64-V8: +# RUN: yaml2obj %s -o %t.arm -DSUBTYPE=0x1 +# RUN: llvm-readobj -h %t.arm \ +# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.arm --check-prefix=ARM64-V8 + +# ARM64-V8:File: [[FILE]] +# ARM64-V8-NEXT:Format: Mach-O arm64 +# ARM64-V8-NEXT:Arch: aarch64 +# ARM64-V8-NEXT:AddressSize: 64bit +# ARM64-V8-NEXT:MachHeader { +# ARM64-V8-NEXT: Magic: Magic64 (0xFEEDFACF) +# ARM64-V8-NEXT: CpuType: Arm64 (0x100000C) +# ARM64-V8-NEXT: CpuSubType: CPU_SUBTYPE_ARM64_V8 (0x1) +# ARM64-V8-NEXT: FileType: Relocatable (0x1) +# ARM64-V8-NEXT: NumOfLoadCommands: 0 +# ARM64-V8-NEXT: SizeOfLoadCommands: 0 +# ARM64-V8-NEXT: Flags [ (0x0) +# ARM64-V8-NEXT: ] +# ARM64-V8-NEXT: Reserved: 0x0 +# ARM64-V8-NEXT:} +# ARM64-V8-NOT:{{.}} + +## Check subtype Arm64E: +# RUN: yaml2obj %s -o %t.arm -DSUBTYPE=0x2 +# RUN: llvm-readobj -h %t.arm \ +# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.arm --check-prefix=ARM64E + +# ARM64E:File: [[FILE]] +# ARM64E-NEXT:Format: Mach-O arm64 +# ARM64E-NEXT:Arch: aarch64 +# ARM64E-NEXT:AddressSize: 64bit +# ARM64E-NEXT:MachHeader { +# ARM64E-NEXT: Magic: Magic64 (0xFEEDFACF) +# ARM64E-NEXT: CpuType: Arm64 (0x100000C) +# ARM64E-NEXT: CpuSubType: CPU_SUBTYPE_ARM64E (0x2) +# ARM64E-NEXT: FileType: Relocatable (0x1) +# ARM64E-NEXT: NumOfLoadCommands: 0 +# ARM64E-NEXT: SizeOfLoadCommands: 0 +# ARM64E-NEXT: Flags [ (0x0) +# ARM64E-NEXT: ] +# ARM64E-NEXT: Reserved: 0x0 +# ARM64E-NEXT:} +# ARM64E-NOT:{{.}} + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x0100000C + cpusubtype: [[SUBTYPE]] + filetype: 0x00000001 + ncmds: 0 + sizeofcmds: 0 + flags: 0x00000000 + reserved: 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 @@ -2109,6 +2109,10 @@ 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"; @@ -8315,6 +8319,9 @@ 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; 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 @@ -161,8 +161,9 @@ }; static const EnumEntry MachOHeaderCpuSubtypesARM64[] = { - LLVM_READOBJ_ENUM_ENT(MachO, CPU_SUBTYPE_ARM64_ALL), - LLVM_READOBJ_ENUM_ENT(MachO, CPU_SUBTYPE_ARM64E), + 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[] = {