fix(errors)!: align unsupported-signature status and split invalid-method-token at its producer (#14230)

* fix(managed)!: report an unsupported signature as partial metadata, not malformed

The refusal path already treats `unsupported-signature` as a valid form
outside decoder coverage, but `managedMetadataFailureStatus` still called
it malformed. One predicate, `isManagedCoverageGap`, now owns that split
for both the refusal and the inventory status.

Value retention no longer reads the inventory status: one value's
unsupported signature is still retained locally, while a budget or an
unsupported metadata layout still stops the whole read.

BREAKING CHANGE: when a managed reader stops on `unsupported-signature`,
`metadata.status` is `partial` (was `malformed`) in managed artifact,
member and native-boundary inspection, and the artifact
`classification.status` is `managed` (was `malformed`). The field names
and enum members are unchanged.

* fix(il2cpp)!: refuse a reused or non-MethodDef token as malformed metadata

`invalid-method-token` covered two facts. A MethodDef row reused within
one image, or a token that is not a nonzero MethodDef row, is in the
metadata's own records; a row past the module's method pointers is a
disagreement between two files that both parse.

The metadata reader now checks each image's tokens while reading link
facts and raises `invalid-method-definition-token`, which the provider
already refuses as a malformed target at the metadata's path. The linker
keeps `invalid-method-token` for the cross-file range check only and drops
its own duplicate scan.

BREAKING CHANGE: a duplicate or non-MethodDef method token found while
linking is `unsupported_target` with `details.path` the metadata file,
`details.format` `il2cpp-metadata`, `details.format_failure` `malformed`
and `details.reason` starting `invalid-method-definition-token:` (was an
`invalid_request` link conflict naming `path` and `binary_path` with
reason `invalid-method-token`). A token past the module's method
pointers keeps the conflict and the `invalid-method-token` reason.
This commit is contained in:
morluto authored and GitHub committed 2026-11-23 20:50:18 -05:00
1 parent 0af067d766
commit eb6c281fec
12 files changed
+239 -71

No files matched your search

@@ -14,6 +14,7 @@ import {
} from "../../fixtures/il2cpp/readers.js";
import {
createIl2cppMetadataFixture,
createLinkedIl2cppMetadataFixture,
FIXTURE_IMAGES,
fixtureImages,
FIXTURE_METHODS,
@@ -208,6 +209,28 @@ describe("rejected IL2CPP global-metadata", () => {
},
);
it.each([
["a MethodDef row reused within one image", (first: number) => first],
["a token outside the MethodDef table", () => 0x0a000002],
["MethodDef row zero", () => 0x06000000],
])("refuses %s as malformed metadata before native linking", (_, token) => {
const fixture = createLinkedIl2cppMetadataFixture({ version: 31 });
const bytes = Buffer.from(fixture.bytes);
// Methods 0 and 1 belong to the same image; the token is at offset 24.
const first = bytes.readUInt32LE(fixture.record("methods", 0) + 24);
bytes.writeUInt32LE(token(first), fixture.record("methods", 1) + 24);
// The public inventory does not read tokens, so it is unaffected.
expect(readIl2cppMetadata(bytes).methods).toHaveLength(
readIl2cppMetadata(fixture.bytes).methods.length,
);
const rejected = failure(bytes, readIl2cppMetadataForLinking);
expect(rejected).toMatchObject({
reason: "invalid-method-definition-token",
kind: "malformed",
failure: { format: "il2cpp-metadata" },
});
});
it("uses the same truncated-prefix classification before native linking", () => {
const bytes = Buffer.alloc(7);
bytes.writeUInt32LE(0xfab11baf, 0);