fix: bind identity and coverage to the producing rule (#1513)
* fix: bind identity and coverage to the producing rule Logical paths, container families, examined bytes, path-segment conventions, destination collisions, file-id leases, Mach-O CPU selection, and firmware cleanup now follow the observation that owns each rule. * fix: fail unmatched Mach-O slices and keep firmware roots independent A fat target whose architecture lipo did not list now stops before slice tools run. Chained fixups still count unread LC_DYLD_INFO rebase bytes, and a firmware cleanup failure no longer blocks the next workspace. * test: cover path identity and runtime families at the projection boundary NFC joins and segment conventions are now asserted by the path resolver, the Apple projection, and a real APK inventory instead of helper unit tests. * test: expect unread dyld rebase bytes in the Apple dispatch fixture The legacy LC_DYLD_INFO fixture keeps a rebase range this reader does not decode, so the public CLI and MCP check now requires that partial coverage beside the bind opcodes. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,11 @@ import type { DecodeIssue } from "./AppleDispatchDecodeFacts.js";
|
||||
export interface FixupCommands {
|
||||
/** Absolute file range of `LC_DYLD_CHAINED_FIXUPS` data. */
|
||||
readonly chained: { readonly offset: number; readonly size: number } | null;
|
||||
/** Absolute file ranges of `LC_DYLD_INFO(_ONLY)` rebase streams. */
|
||||
readonly rebases: readonly {
|
||||
readonly offset: number;
|
||||
readonly size: number;
|
||||
}[];
|
||||
/** Absolute file ranges of `LC_DYLD_INFO(_ONLY)` bind streams. */
|
||||
readonly binds: readonly {
|
||||
readonly offset: number;
|
||||
@@ -35,6 +40,10 @@ export interface PointerFixups {
|
||||
readonly formats: readonly string[];
|
||||
readonly failures: readonly string[];
|
||||
readonly issues: readonly DecodeIssue[];
|
||||
/** Fixup segments or bind streams this reader walked. */
|
||||
readonly examined: number;
|
||||
/** Rebase opcode bytes present in the load command and not decoded. */
|
||||
readonly unreadRebaseBytes: number;
|
||||
/** Decode the pointer stored at `address` whose raw 64-bit value is `raw`. */
|
||||
decode(address: bigint, raw: bigint): DecodedPointer;
|
||||
}
|
||||
@@ -250,6 +259,8 @@ const chainedFixups = (
|
||||
formats,
|
||||
failures: issues.map(({ message }) => message),
|
||||
issues,
|
||||
examined: Math.max(ranges.length, 1),
|
||||
unreadRebaseBytes: 0,
|
||||
decode(address, raw) {
|
||||
const segment = ranges.find(
|
||||
({ from, to }) => address >= from && address < to,
|
||||
@@ -420,13 +431,24 @@ export const parsePointerFixups = (
|
||||
baseAddress: bigint,
|
||||
): PointerFixups => {
|
||||
const image = { bytes, segments, dylibs: commands.dylibs, baseAddress };
|
||||
if (commands.chained !== null) return chainedFixups(image, commands.chained);
|
||||
const unreadRebaseBytes = commands.rebases.reduce(
|
||||
(total, rebase) => total + rebase.size,
|
||||
0,
|
||||
);
|
||||
if (commands.chained !== null) {
|
||||
const chained = chainedFixups(image, commands.chained);
|
||||
return unreadRebaseBytes === 0
|
||||
? chained
|
||||
: { ...chained, unreadRebaseBytes };
|
||||
}
|
||||
if (commands.binds.length === 0)
|
||||
return {
|
||||
kind: "none",
|
||||
formats: [],
|
||||
failures: [],
|
||||
issues: [],
|
||||
examined: 0,
|
||||
unreadRebaseBytes,
|
||||
decode: (_address, raw) => ({ kind: "rebase", target: raw }),
|
||||
};
|
||||
const binds = new Map<bigint, Import>();
|
||||
@@ -446,6 +468,8 @@ export const parsePointerFixups = (
|
||||
issues: failures.map((message) =>
|
||||
issue("pointer_fixups", "bind_stream_decode_failed", message),
|
||||
),
|
||||
examined: commands.binds.length,
|
||||
unreadRebaseBytes,
|
||||
decode(address, raw) {
|
||||
const bound = binds.get(address);
|
||||
return bound === undefined
|
||||
|
||||
Reference in New Issue
Block a user