fix(limits)!: make the IL2CPP pointer index adjustable and require owned refusal limits (#14243)

* fix(limits): make the IL2CPP pointer index adjustable and name ELF note budgets in details.limit

inspect_il2cpp_metadata accepts max_native_index_bytes (default 1 GiB,
needs binary_path) for the estimated ELF virtual pointer index. The index
refusal now carries its own limit name (virtual-pointer-index-bytes) and a
details.limit naming the parameter, its effective value, default and range,
instead of a fixed ceiling with no override. The binary file allowance and
the loader's fixed capacities are unchanged.

inspect_elf_notes and inspect_elf_debug_link refusals for max_file_bytes,
the decoded section-name budget and max_entries now set details.limit. One
domain-owned bounds object per operation feeds both the schema and the limit.

Two guards keep new in-code refusal limits owned:
- scripts/verify/fixed-ceilings.mjs (run by npm run lint) requires every
  fixedAllowanceOptions, fixedProducerInputAllowance,
  artifactFixedLimitFailure or inline fixedAllowance declaration to be
  listed in fixed-ceiling-registry.json with its class (format, protocol,
  representation, derived, forwarding, or pending with an issue) and reason,
  and fails on stale entries.
- The untyped-budget-refusal architecture guard counts refusals whose only
  recovery is an authored remediationAction, with a shrink-only baseline.

Fixes #14175
Part of #14234

BREAKING CHANGE: an inspect_il2cpp_metadata refusal at the ELF pointer index
reports reported_limits.boundary "virtual-pointer-index-bytes" and
details.limit for max_native_index_bytes, and no longer carries a
details.refusal fixed_ceiling.

* fix(limits): track IL2CPP's remaining fixed allowances with the native readers

* fix(limits): run the authored-only refusal count from lint, where TypeScript is installed

The architecture guards run before npm ci in CI and must stay
dependency-free, so the AST-based count moves into fixed-ceilings.mjs with
its own shrink-only baseline and --shrink-baselines.

* fix(limits): register producer and native wrapper ceilings by the allowance they name

fixedProducerInputAllowance names its allowance in its second argument, and
fixedNativeAllowance forwards its first, so the guard now reads each helper's
allowance argument and checks the callers of both.

* fix(limits): delete the authored-only baseline when its last count is removed

reconcileBaselineFile returns delete once no count remains, but the
verifier ignored it and the next run read the file unconditionally, so
--shrink-baselines could not finish. An absent baseline now reads as empty
and shrinking removes the file.

* fix(limits): record the advertised IL2CPP input schema with max_native_index_bytes
This commit is contained in:
morluto authored and GitHub committed 2026-11-23 23:37:23 -05:00
1 parent 90d774ffed
commit 6ab595cfd6
28 files changed
+1623 -28

No files matched your search

+42
View File
@@ -7,6 +7,7 @@ import {
} from "../localPath.js";
import { canonicalBase64Schema } from "../stringPatterns.js";
import type { MachoSliceArchitecture } from "../apple/machoTargetSelection.js";
import type { AnalysisParameterLimit } from "../analysisSettings.js";
import { firstDeclaringTypeCycle } from "./il2cppDeclaringTypes.js";
/** The public `binary_architecture` values, in the native reader's spelling. */
@@ -25,6 +26,33 @@ export const IL2CPP_SLICE_SELECTORS = {
>;
export type Il2cppBinaryArchitecture = keyof typeof IL2CPP_SLICE_SELECTORS;
/**
* Estimated representation bytes admitted for an ELF binary's virtual pointer
* index when `max_native_index_bytes` is omitted. The index reserves a fixed
* logical charge per distinct relocated address, so this default admits
* 524,288 addresses. It is an REA admission policy, not a format limit.
*/
export const DEFAULT_IL2CPP_NATIVE_INDEX_BYTES = 1024 * 1024 * 1024;
/**
* The per-call control that bounded the ELF virtual pointer index, named by
* its contract field; each adapter names the option that sets it. The
* accounting is exact safe-integer arithmetic, so the control has no smaller
* maximum; host heap remains an independent constraint.
*/
export const il2cppNativeIndexLimit = (
effectiveBytes: number,
): AnalysisParameterLimit => ({
control_kind: "parameter",
parameter: "max_native_index_bytes",
effective_value: effectiveBytes,
unit: "bytes",
minimum: 1,
maximum: Number.MAX_SAFE_INTEGER,
default_value: DEFAULT_IL2CPP_NATIVE_INDEX_BYTES,
applies_at: "next_call",
});
/** Unsigned little-endian signature observed at file offset zero. */
export const IL2CPP_METADATA_MAGIC = 0xfab11baf;
@@ -135,6 +163,14 @@ export const inspectIl2cppMetadataInputSchema = requirePresence(
.describe(
"Also link generic method instances (genericMethodTable rows) to code addresses with Il2CppDumper-style Type<Args>$$Method<Args> names; needs binary_path",
),
max_native_index_bytes: z
.int()
.positive()
.max(Number.MAX_SAFE_INTEGER)
.optional()
.describe(
`Estimated bytes admitted for an ELF binary_path's relocated-pointer index, charged per distinct relocated address; omitted means ${String(DEFAULT_IL2CPP_NATIVE_INDEX_BYTES)} (1 GiB). Raise it on the next call when linking stops at this allowance; no restart. Host memory and the binary file allowance stay independent. Needs binary_path`,
),
}),
[
{
@@ -148,6 +184,12 @@ export const inspectIl2cppMetadataInputSchema = requirePresence(
requires: "binary_path",
message: "generic_instances links generic methods in binary_path.",
},
{
when: "max_native_index_bytes",
requires: "binary_path",
message:
"max_native_index_bytes bounds the pointer index of binary_path.",
},
],
);