refactor(il2cpp): share stored native image scalar reads (#12638)

refactor(il2cpp): share native registration scalar reads
This commit is contained in:
morluto authored and GitHub committed 2026-11-20 01:13:26 +00:00
1 parent 3ce6cd8a84
commit 21dfefcfb2
6 files changed
+52 -33

No files matched your search

@@ -586,6 +586,34 @@ it.each([
).toBe("code-registration-not-found");
});
it.each([
["x86-64", 7],
["arm64", 8],
] as const)(
"keeps the entire %s registration reference inside the executable extent",
(arch, width) => {
const instruction = 0xc00;
const makeImage = (inside: number) => {
const bytes = createIl2cppBinaryFixture({
codeRegistration: false,
codeReference: arch === "x86-64",
adrpAdd: arch === "arm64" ? [[instruction, 0x500]] : [],
splitSegmentAt: instruction + inside,
});
if (arch === "x86-64") bytes.writeUInt32LE(0x01000007, 4);
bytes.writeUInt32LE(1, 32 + 72 + 60); // The second segment is read-only.
return bytes;
};
expect(link(makeImage(width)).code_gen_modules_array).toBe(
FIXTURE_BINARY_BASE + 0x500n,
);
expect(failure(makeImage(width - 1))).toMatchObject({
reason: "code-registration-not-found",
kind: "malformed",
});
},
);
it("finds an arm64 module array through the ADRP+ADD pair that loads it", () => {
const linked = link(
createIl2cppBinaryFixture({