[PR #1709] [MERGED] fix(native): honor Mach-O chained pointer locations and library ordinals #4773

Closed
opened 2026-10-31 00:54:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1709
Author: @1NormalGuy
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @baron

Base: main ← Head: fix/macho-chained-pointer-decoding


📝 Commits (7)

  • 344be44 fix(native): honor Mach-O chained pointer locations and library ordinals
  • 5adc446 perf(native): reuse parsed Mach-O chain membership
  • 2088d1f test(native): validate parsed-chain repair against local gates
  • 11bd4ef test(native): pin chained fixup page failure provenance
  • 805f6c7 fix(native): bound parsed chained page facts and metadata
  • eebf580 chore(native): integrate latest main for chained fixup validation
  • dd938d7 test(server): pin shared partial Evidence provenance

📊 Changes

5 files changed (+957 additions, -42 deletions)

View changed files

📝 scripts/verify/apple/dispatch.mjs (+2 -0)
📝 src/native/AppleDispatchMetadata.test.ts (+34 -0)
📝 src/native/AppleMachoFixups.test.ts (+566 -18)
📝 src/native/AppleMachoFixups.ts (+230 -23)
📝 tests/boundary/mcp/targetContentFramingMcp.test.ts (+125 -1)

📄 Description

Summary

Restore correct Mach-O pointer decoding and dylib provenance for ObjC/Swift metadata. These defects were reproduced during repository review; there is no related issue.

Problem and expected behavior

LC_DYLD_CHAINED_FIXUPS describes individual pointer locations, but the parser decoded every nonzero pointer in the containing segment. An ordinary 0x100001234 pointer could become 0x200001234, corrupting metadata lookup. A chain-member zero was also treated as null, and valid positive dylib ordinals above the signed integer midpoint lost their library identity.

Only declared chain members should be decoded. Ordinary interleaved pointers, zero-offset rebases and valid dependency identities must remain accurate.

Change and scope

Walk declared page starts and next links, decode only chain members, and use dyld's special-ordinal cutoffs. Validate producer bounds, preserve known facts after malformed chains and expose partial coverage. Give the Swift verifier an explicit module name so hyphenated fixture filenames compile.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Mach-O fixup parsing.
  • CLI and MCP/tool-catalog contract: no schema changes; corrected metadata addresses and library provenance.
  • Provider, bridge, target-format, or platform compatibility: Mach-O chained fixups and the existing supported pointer formats.
  • Evidence, artifact, provenance, or reconstruction contract: preserve dependency identity, ordinary pointer values and explicit incomplete coverage.
  • Process execution, authorization, cleanup, or containment impact: none; inspected target fixtures were not executed.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: chain membership, zero-offset rebases, malformed page starts/links, ordinal boundaries and interleaved ObjC metadata.

  • Base reproductions confirmed ordinary pointer corruption, incorrect null treatment and missing library provenance.

  • User-visible CLI/MCP output: classes, categories, implementation addresses, conformances and witness slots are recovered from 10 compiled fixture variants; ordinary pointer addresses are preserved.

  • Remaining proof gaps: verification covers the selected macOS fixture variants, not all third-party binaries.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Validated this standalone PR branch:

  • npm run test:focused -- src/native/AppleMachoFixups.test.ts src/native/AppleDispatchMetadata.test.ts — 46 tests passed.
  • npm run verify:apple-dispatch — 10 real ObjC/Swift fixture variants passed through public CLI/MCP (arm64/arm64e, chained/legacy fixups, symbols/stripped); target code was not executed. Required runtime/skill artifacts built successfully.
  • npm run check — passed, including typecheck, lint (0 errors), formatting, dependency/metadata checks, module boundaries and architecture guards.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real compiled macOS fixture inspection; Hopper/Ghidra/browser not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: read-only parsing, bounded chain walks and no target execution.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1709 **Author:** [@1NormalGuy](https://github.com/1NormalGuy) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@baron](https://github.com/baron) **Base:** `main` ← **Head:** `fix/macho-chained-pointer-decoding` --- ### 📝 Commits (7) - [`344be44`](https://github.com/morluto/rea/commit/344be44f9a51c3f87b8d2ff7d086c86f1afcb6f0) fix(native): honor Mach-O chained pointer locations and library ordinals - [`5adc446`](https://github.com/morluto/rea/commit/5adc4463e5ada80d62ec797b19e708c0598c9b86) perf(native): reuse parsed Mach-O chain membership - [`2088d1f`](https://github.com/morluto/rea/commit/2088d1fa0cb1fdbcd5931637433df70e9659b359) test(native): validate parsed-chain repair against local gates - [`11bd4ef`](https://github.com/morluto/rea/commit/11bd4ef4c021baec79608d46ccf0d2e58de2735a) test(native): pin chained fixup page failure provenance - [`805f6c7`](https://github.com/morluto/rea/commit/805f6c7eecf2d765a7b42853f2a9e80664027d03) fix(native): bound parsed chained page facts and metadata - [`eebf580`](https://github.com/morluto/rea/commit/eebf580dea62ef9bba2d11608b0a113723404955) chore(native): integrate latest main for chained fixup validation - [`dd938d7`](https://github.com/morluto/rea/commit/dd938d70dffff7c4c88c5d4c1be8962c0213815c) test(server): pin shared partial Evidence provenance ### 📊 Changes **5 files changed** (+957 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `scripts/verify/apple/dispatch.mjs` (+2 -0) 📝 `src/native/AppleDispatchMetadata.test.ts` (+34 -0) 📝 `src/native/AppleMachoFixups.test.ts` (+566 -18) 📝 `src/native/AppleMachoFixups.ts` (+230 -23) 📝 `tests/boundary/mcp/targetContentFramingMcp.test.ts` (+125 -1) </details> ### 📄 Description ## Summary Restore correct Mach-O pointer decoding and dylib provenance for ObjC/Swift metadata. These defects were reproduced during repository review; there is no related issue. ## Problem and expected behavior `LC_DYLD_CHAINED_FIXUPS` describes individual pointer locations, but the parser decoded every nonzero pointer in the containing segment. An ordinary `0x100001234` pointer could become `0x200001234`, corrupting metadata lookup. A chain-member zero was also treated as null, and valid positive dylib ordinals above the signed integer midpoint lost their library identity. Only declared chain members should be decoded. Ordinary interleaved pointers, zero-offset rebases and valid dependency identities must remain accurate. ## Change and scope Walk declared page starts and next links, decode only chain members, and use dyld's special-ordinal cutoffs. Validate producer bounds, preserve known facts after malformed chains and expose partial coverage. Give the Swift verifier an explicit module name so hyphenated fixture filenames compile. ## Contract and boundary impact - Semantic owner and earliest changed stage: Mach-O fixup parsing. - CLI and MCP/tool-catalog contract: no schema changes; corrected metadata addresses and library provenance. - Provider, bridge, target-format, or platform compatibility: Mach-O chained fixups and the existing supported pointer formats. - Evidence, artifact, provenance, or reconstruction contract: preserve dependency identity, ordinary pointer values and explicit incomplete coverage. - Process execution, authorization, cleanup, or containment impact: none; inspected target fixtures were not executed. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: chain membership, zero-offset rebases, malformed page starts/links, ordinal boundaries and interleaved ObjC metadata. - Base reproductions confirmed ordinary pointer corruption, incorrect null treatment and missing library provenance. - User-visible CLI/MCP output: classes, categories, implementation addresses, conformances and witness slots are recovered from 10 compiled fixture variants; ordinary pointer addresses are preserved. - Remaining proof gaps: verification covers the selected macOS fixture variants, not all third-party binaries. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Validated this standalone PR branch: - `npm run test:focused -- src/native/AppleMachoFixups.test.ts src/native/AppleDispatchMetadata.test.ts` — 46 tests passed. - `npm run verify:apple-dispatch` — 10 real ObjC/Swift fixture variants passed through public CLI/MCP (arm64/arm64e, chained/legacy fixups, symbols/stripped); target code was not executed. Required runtime/skill artifacts built successfully. - `npm run check` — passed, including typecheck, lint (0 errors), formatting, dependency/metadata checks, module boundaries and architecture guards. - `git diff --check` — passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: real compiled macOS fixture inspection; Hopper/Ghidra/browser not applicable. - Package or release metadata impact: none. - Security, privacy, process, or containment review: read-only parsing, bounded chain walks and no target execution. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:54:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4773
No description provided.