From f598bab488e38c378d69346fa3c106f9e18529ed Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 11 Oct 2026 23:52:42 +0800 Subject: [PATCH] fix(apple): preserve ARM64E X1 architecture identity --- src/artifacts/apple/MachoLoadCommandReader.ts | 6 +++- .../artifactProvider.machOSlices.test.ts | 31 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/artifacts/apple/MachoLoadCommandReader.ts b/src/artifacts/apple/MachoLoadCommandReader.ts index 561c2b84f..8a0112fab 100644 --- a/src/artifacts/apple/MachoLoadCommandReader.ts +++ b/src/artifacts/apple/MachoLoadCommandReader.ts @@ -526,12 +526,16 @@ const CPU_TYPE_X86 = 7; const CPU_TYPE_ARM = 12; const CPU_SUBTYPE_MASK = 0xff000000; const CPU_SUBTYPE_ARM64E = 2; +const CPU_SUBTYPE_ARM64E_X1 = 12; const CPU_SUBTYPE_X86_64_H = 8; const architectureName = (cpuType: number, cpuSubtype: number): string => { const subtype = cpuSubtype & ~CPU_SUBTYPE_MASK; if (cpuType === (CPU_TYPE_ARM | CPU_ARCH_ABI64)) - return subtype === CPU_SUBTYPE_ARM64E ? "arm64e" : "arm64"; + // Both pointer-authentication subtypes belong to the arm64e family. + return subtype === CPU_SUBTYPE_ARM64E || subtype === CPU_SUBTYPE_ARM64E_X1 + ? "arm64e" + : "arm64"; if (cpuType === (CPU_TYPE_ARM | CPU_ARCH_ABI64_32)) return "arm64_32"; if (cpuType === (CPU_TYPE_X86 | CPU_ARCH_ABI64)) return subtype === CPU_SUBTYPE_X86_64_H ? "x86_64h" : "x86_64"; diff --git a/tests/boundary/providers/native/artifactProvider.machOSlices.test.ts b/tests/boundary/providers/native/artifactProvider.machOSlices.test.ts index 8de8212bf..812cc2df7 100644 --- a/tests/boundary/providers/native/artifactProvider.machOSlices.test.ts +++ b/tests/boundary/providers/native/artifactProvider.machOSlices.test.ts @@ -218,6 +218,8 @@ const lipoRunner = (stdout: string): NativeCommandRunner => ({ // the same slice `arm64e`, and its physical identity must still match. describe("artifact Mach-O arm64e variant slices", () => { const ARM64E_V1 = { type: 0x0100000c, subtype: 0x81000002 } as const; + // CPU_SUBTYPE_ARM64E_X1 (12) with the pointer-auth ABI bit, as in macOS 27 /bin/ls. + const ARM64E_X1 = { type: 0x0100000c, subtype: 0x8000000c } as const; const variantSlices = async ( cpu: { readonly type: number; readonly subtype: number }, lipo: (size: number) => string, @@ -249,24 +251,29 @@ describe("artifact Mach-O arm64e variant slices", () => { it.each([ [ "arm64e.v1", + ARM64E_V1, " cputype CPU_TYPE_ARM64\n cpusubtype CPU_SUBTYPE_ARM64E\n capabilities PTR_AUTH_VERSION USERSPACE 1", ], [ "arm64e.x1", + ARM64E_X1, " cputype CPU_TYPE_ARM64\n cpusubtype unknown arm64 cpusubtype", ], - ])("accepts lipo's %s name for the FAT arm64e slice", async (name, cpu) => { - expect( - await variantSlices( - ARM64E_V1, - (size) => - `architecture ${name}\n${cpu}\n offset 8192\n size ${String(size)}\n align 2^12 (4096)\n`, - ), - ).toEqual([ - ["slices/x86_64", 4096], - [`slices/${name}`, 8192], - ]); - }); + ])( + "accepts lipo's %s name for the FAT arm64e slice", + async (name, fatCpu, cpu) => { + expect( + await variantSlices( + fatCpu, + (size) => + `architecture ${name}\n${cpu}\n offset 8192\n size ${String(size)}\n align 2^12 (4096)\n`, + ), + ).toEqual([ + ["slices/x86_64", 4096], + [`slices/${name}`, 8192], + ]); + }, + ); it.each([ ["a plain arm64 slice", CPU.arm64, "8192"],