fix(apple): preserve ARM64E X1 architecture identity
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user