mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
fix(elf): recover pointers from Android APS2 relocation tables (#12047)
This commit is contained in:
1 parent
c47442a2eb
commit
32b2020571
22 files changed
+1150
-242
No files matched your search
@@ -67,6 +67,18 @@ const link = (bytes: Buffer, architecture?: Il2cppBinaryArchitecture) =>
|
||||
metadata,
|
||||
facts,
|
||||
);
|
||||
it.each([183, 62])(
|
||||
"links IL2CPP registration and method pointers through APS2 on machine %d",
|
||||
(machine) => {
|
||||
const bytes = createElfFixture(createIl2cppBinaryFixture(), {
|
||||
machine,
|
||||
androidPacked: "aps2",
|
||||
});
|
||||
const original = Buffer.from(bytes);
|
||||
expect(link(bytes).method_addresses).toEqual(expectedAddresses);
|
||||
expect(bytes.equals(original)).toBe(true);
|
||||
},
|
||||
);
|
||||
it.each([183, 62])(
|
||||
"links past unrelated ABS64 and GLOB_DAT records on ELF machine %d",
|
||||
(machine) => {
|
||||
@@ -501,17 +513,23 @@ it("does not apply symbol relocations as RELATIVE ones", () => {
|
||||
).toThrow(Il2cppBinaryFormatFailure);
|
||||
});
|
||||
|
||||
it("reads a method pointer array in zero-fill as methods without bodies", () => {
|
||||
// An iOS-only assembly in an Android build keeps its array in .bss.
|
||||
const linked = link(
|
||||
createElfFixture(createIl2cppBinaryFixture(), { zeroFilledTable: true }),
|
||||
);
|
||||
expect(linked.method_addresses).toEqual([
|
||||
...expectedAddresses.slice(0, 3),
|
||||
expectedAddress("no-body"),
|
||||
expectedAddress("no-body"),
|
||||
]);
|
||||
});
|
||||
it.each([undefined, "aps2"] as const)(
|
||||
"reads a method pointer array in zero-fill as methods without bodies (packing: %s)",
|
||||
(androidPacked) => {
|
||||
// An iOS-only assembly in an Android build keeps its array in .bss.
|
||||
const linked = link(
|
||||
createElfFixture(createIl2cppBinaryFixture(), {
|
||||
zeroFilledTable: true,
|
||||
...(androidPacked === undefined ? {} : { androidPacked }),
|
||||
}),
|
||||
);
|
||||
expect(linked.method_addresses).toEqual([
|
||||
...expectedAddresses.slice(0, 3),
|
||||
expectedAddress("no-body"),
|
||||
expectedAddress("no-body"),
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it("reads a PE pointer array across file bytes and the declared zero-fill tail", () => {
|
||||
const bytes = createSplitPointerPeFixture();
|
||||
@@ -1106,7 +1124,7 @@ it.each(["outside", "misaligned", "duplicate"] as const)(
|
||||
it.each([
|
||||
[{ dynamic: false }, "unsupported-container"],
|
||||
[{ machine: 243 }, "unsupported-container"],
|
||||
[{ androidPacked: true }, "unsupported-pointer-encoding"],
|
||||
[{ androidPacked: "aps1" }, "unsupported-pointer-encoding"],
|
||||
] as const)(
|
||||
"refuses ELF relocations it cannot apply (%o)",
|
||||
(options, reason) => {
|
||||
|
||||
Reference in new issue
Block a user