fix(managed): admit ReadyToRun images built for non-Windows hosts (#1985)

ReadyToRun images compiled for Linux, macOS or the BSDs store the COFF machine XORed with IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE (dotnet/runtime src/coreclr/inc/pedecoder.h). Every framework assembly in a Linux .NET install has machine 0xFD1D, so target admission and the managed PE reader rejected them as an unsupported architecture.

Decode the PE machine once in src/domain/peMachine.ts, replacing the two duplicated switches, and accept an OS override only on images with a CLI directory.
This commit is contained in:
Jeremy Levartovsky
2026-10-12 08:41:23 +08:00
committed by GitHub
parent 43f9c39dfb
commit 0d11f71e0d
6 changed files with 168 additions and 40 deletions
@@ -46,6 +46,14 @@ describe("managed artifact failure classification", () => {
]);
});
it("rejects a ReadyToRun OS-override machine without a CLI directory", () => {
const bytes = buildNativePeFixture();
bytes.writeUInt16LE(0x014c ^ 0x7b79, bytes.readUInt32LE(0x3c) + 4);
expect(() =>
inspectManagedArtifactBytes(bytes, managedPeFixtureTarget(bytes)),
).toThrow("Unsupported PE machine 0x7a35");
});
it("keeps malformed reference and attribute issues across inventory callers", () => {
const bytes = buildManagedPeFixture({
references: [