mirror of
https://github.com/morluto/rea.git
synced 2026-11-06 23:06:18 +00:00
Reuse the existing provider input admission helper across twelve services, preserving cancellation, schema errors, path policies, and Evidence handling. Share ELF dynamic records across Dart, MIPS, and IL2CPP readers, and reuse Mach-O segment and section records for Node SEA location. Require canonical DOS ownership before GPU PE section discovery so relocation bytes cannot masquerade as a PE pointer. Cover valid short DOS headers and the malformed case through both inventory and the public CLI.
25 lines
737 B
TypeScript
25 lines
737 B
TypeScript
import { err, ok } from "./result.js";
|
|
|
|
/** Fixed Elf32_Dyn/Elf64_Dyn: signed d_tag and unsigned d_un, without tag or value admission. */
|
|
export const readElfDynamicEntry = (
|
|
bytes: Uint8Array,
|
|
bits: 32 | 64,
|
|
littleEndian: boolean,
|
|
) => {
|
|
const wide = bits === 64;
|
|
if (bytes.byteLength < (wide ? 16 : 8))
|
|
return err({
|
|
kind: "malformed" as const,
|
|
message: "ELF dynamic entry is truncated",
|
|
});
|
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
return ok({
|
|
tag: wide
|
|
? view.getBigInt64(0, littleEndian)
|
|
: BigInt(view.getInt32(0, littleEndian)),
|
|
value: wide
|
|
? view.getBigUint64(8, littleEndian)
|
|
: BigInt(view.getUint32(4, littleEndian)),
|
|
});
|
|
};
|