fix(macho): recognize arm64_32 binaries

Fixes #6581
This commit is contained in:
morluto
2026-10-23 18:04:27 +08:00
parent 379f37307a
commit abbb1d7135
3 changed files with 51 additions and 0 deletions
+1
View File
@@ -156,6 +156,7 @@ export const readMachoImage = (bytes: Buffer): BinaryContainer => {
[0x01000007, "amd64"],
[12, "arm"],
[0x0100000c, "arm64"],
[0x0200000c, "arm64_32"],
[18, "ppc"],
[0x01000012, "ppc64"],
]);
+33
View File
@@ -119,6 +119,39 @@ cliTest("returns null metadata when .dep-v0 is absent", async ({ cli }) => {
);
});
cliTest(
"keeps arm64_32 in Rust CLI Evidence when dependency metadata is absent",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-rust-arm64-32-");
const path = join(root, "watchos-object");
const bytes = createRustImage({
format: "macho",
omitSection: true,
includeRustc: false,
});
bytes.writeUInt32LE(0x0200000c, 4);
await writeFile(path, bytes);
const result = await cli.run({
arguments: ["inspect-rust-binary", path, "--json"],
});
expect(result.exitCode, result.stderr).toBe(0);
const evidence = toolContract("inspect_rust_binary").outputSchema.parse(
result.json,
);
expect(evidence.subject).toMatchObject({
format: "mach-o",
architecture: "arm64_32",
});
expect(rustBinarySchema.parse(evidence.normalized_result)).toMatchObject({
architecture: "arm64_32",
bits: 64,
auditable_metadata: null,
});
},
);
cliTest(
"preserves an unknown cargo-auditable revision and reports its fallback",
async ({ cli }) => {
@@ -70,6 +70,23 @@ it("reads a Mach-O __DATA,.dep-v0 section", () => {
});
});
it("preserves the arm64_32 Mach-O CPU family when dependency metadata is absent", () => {
const bytes = createRustImage({
format: "macho",
omitSection: true,
includeRustc: false,
});
bytes.writeUInt32LE(0x0200000c, 4);
expect(readRustBinaryImage(bytes)).toMatchObject({
format: "macho",
architecture: "arm64_32",
bits: 64,
auditable_metadata: null,
rustc_commit: null,
});
});
it("ignores PE file-alignment padding after the dependency content", () => {
const bytes = createRustImage({ format: "pe", includeRustc: false });
const payloadBytes = rustDependencyPayload().length;