Files
reverse-engineering-anything/src/domain/elfDynamicEntry.ts
T
morluto 6336fe5bb5 refactor: consolidate binary analysis admission and format ownership
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.
2026-10-26 16:44:21 +08:00

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)),
});
};