Files
rea/src/go/GoMachoImage.alignment.test.ts
T
morluto c19c2d6723 fix(native): separate container facts from Go metadata admission
Move ELF, PE and Mach-O container parsing into a shared native owner. Go alone selects and validates Go build-info sections, so unrelated malformed Go metadata no longer blocks Rust dependency or IL2CPP inspection. Remove the superseded Go-specific container representation and migrate all consumers. Adapted from draft PR #5510 without asserting human PR readiness.

Validation: 51 compiled CLI/MCP acceptance tests across Rust, Go and IL2CPP; 186 shared-reader tests; full check:ci passed. Three public synthetic-file probes reproduce the baseline Rust refusal and validate the fixed SDK-advertised MCP output, artifact digests and unchanged bytes. The exact zero-address nonallocated ELF case now succeeds for Rust while Go still reports invalid_format. No target execution or real compiler-artifact qualification was performed; no performance improvement is claimed.

Closes #3398
2026-10-21 11:58:15 +08:00

31 lines
836 B
TypeScript

import { expect, it } from "vitest";
import { machoImageWithUnknownCommand } from "../artifacts/apple/MachoImage.fixture.js";
import { readGoBinaryImage } from "./GoBinaryImage.js";
it("rejects a 12-byte load command in a 64-bit Go Mach-O image", () => {
expect(() =>
readGoBinaryImage(Buffer.from(machoImageWithUnknownCommand(true, 12))),
).toThrow(
expect.objectContaining({
name: "BinaryFormatFailure",
kind: "malformed",
}),
);
});
it.each([
{ wide: true, size: 16, bits: 64 },
{ wide: false, size: 12, bits: 32 },
])(
"accepts $bits-bit Mach-O load commands of size $size",
({ wide, size, bits }) => {
expect(
readGoBinaryImage(Buffer.from(machoImageWithUnknownCommand(wide, size))),
).toMatchObject({
format: "macho",
bits,
build_info: null,
});
},
);