[PR #6707] [CLOSED] fix(macho): label legacy Intel version-min images as simulators #7396

Closed
opened 2026-11-01 21:47:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6707
Author: @Sriram-PR
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/macho-legacy-simulator-platform


📝 Commits (1)

  • d22038f fix(macho): label legacy Intel version-min images as simulators

📊 Changes

4 files changed (+76 additions, -10 deletions)

View changed files

📝 src/artifacts/apple/MachoLoadCommandReader.ts (+21 -5)
📝 src/native/parsers/otool.ts (+19 -3)
📝 tests/boundary/providers/native/nativeLoadKinds.golden.test.ts (+31 -0)
📝 tests/fixtures/nativeCommands.ts (+5 -2)

📄 Description

Summary

inspect_native_macho build metadata takes the platform of a legacy LC_VERSION_MIN_* command straight from the command name, so an old x86_64 iOS simulator image reports IPHONEOS with exhaustive coverage and no limitation. Same for x86_64 tvOS and x86_64/i386 watchOS. The direct Mach-O reader (MachoLoadCommandReader.ts) already applies dyld's CPU-type rule here; the otool path didn't.

Fixes #6649

Problem and expected behavior

Smallest trigger: parseOtoolLoadCommands on otool output with cputype 16777223 (x86_64) and cmd LC_VERSION_MIN_IPHONEOS. Main returns [{"platform":"IPHONEOS",...}]. dyld (mach_o/UnsafeHeader.cpp, forEachPlatform) treats IPHONEOS and WATCHOS on x86_64 or i386, and TVOS on x86_64 only, as the simulator ("old sim binary"). Expected: IOSSIMULATOR, WATCHOSSIMULATOR, TVOSSIMULATOR, the names LC_BUILD_VERSION codes 7/8/9 already get in the same parser.

Change and scope

  • The CPU-type rule from legacyVersionMinPlatform moved into an exported isLegacyVersionMinSimulator(os, cpuType) in MachoLoadCommandReader.ts. The binary reader uses it for its PLATFORM_* numbers (same results as before) and the otool parser uses it too, so there's one copy of the rule.
  • otool.ts keeps the header cputype in the load-command state and names simulator images with the existing simulator spellings. Device images keep their current names (IPHONEOS, TVOS, WATCHOS, MACOSX), so output for non-simulator images doesn't change.
  • Not included: renaming the legacy device names to the LC_BUILD_VERSION spelling (IOS, MACOS). That would change output for every legacy image and isn't needed for this bug.

Contribution scope: ordinary fix within existing boundaries; no scope decision needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: collectBuild in src/native/parsers/otool.ts; the rule itself lives in src/artifacts/apple/MachoLoadCommandReader.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix, #6649).
  • CLI and MCP/tool-catalog contract: no schema change. build_metadata.items[].platform for legacy Intel iOS/tvOS/watchOS images changes from the device name to the simulator name.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none beyond the platform value above.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/providers/native/nativeLoadKinds.golden.test.ts adds labels legacy Intel version-minimum images as simulators: x86_64 and i386 iOS, x86_64 tvOS, x86_64 and i386 watchOS give the simulator names; i386 tvOS, x86_64 MACOSX and arm64 iOS/tvOS/watchOS keep their device names. withOtoolMachHeader takes an optional cputype (default stays arm64, so existing fixtures don't change).
  • Base reproduction: the issue's probe returns IPHONEOS on main a281455f. The new test fails on main's source with:
    -   "IOSSIMULATOR",
    +   "IPHONEOS",
    
  • User-visible CLI/MCP output: for the issue's input, build_metadata.items[0].platform is now "IOSSIMULATOR".
  • Remaining proof gaps: synthetic otool captures only; I don't have a macOS host to run real otool on an old simulator build.

For evidence-bearing changes:

  • 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

  • npm run test:focused -- tests/boundary/providers/native/nativeLoadKinds.golden.test.ts: 63 passed (the new test fails on main's source)
  • npm run test:focused -- tests/boundary/providers/native/*.test.ts src/artifacts/apple/*.test.ts: 649 passed, 9 skipped
  • npm run check:fast: typecheck and lint passed
  • npm run verify:module-boundaries: passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none; legacy Intel simulator images now get the right platform name.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux x64, Node 24.18.0, synthetic otool output.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; parsing only.

Author readiness

Human owner: @Sriram-PR

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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/6707 **Author:** [@Sriram-PR](https://github.com/Sriram-PR) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/macho-legacy-simulator-platform` --- ### 📝 Commits (1) - [`d22038f`](https://github.com/morluto/rea/commit/d22038f2b880ed26f231b117f6d190869685379e) fix(macho): label legacy Intel version-min images as simulators ### 📊 Changes **4 files changed** (+76 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/apple/MachoLoadCommandReader.ts` (+21 -5) 📝 `src/native/parsers/otool.ts` (+19 -3) 📝 `tests/boundary/providers/native/nativeLoadKinds.golden.test.ts` (+31 -0) 📝 `tests/fixtures/nativeCommands.ts` (+5 -2) </details> ### 📄 Description ## Summary `inspect_native_macho` build metadata takes the platform of a legacy `LC_VERSION_MIN_*` command straight from the command name, so an old x86_64 iOS simulator image reports `IPHONEOS` with exhaustive coverage and no limitation. Same for x86_64 tvOS and x86_64/i386 watchOS. The direct Mach-O reader (`MachoLoadCommandReader.ts`) already applies dyld's CPU-type rule here; the otool path didn't. Fixes #6649 ## Problem and expected behavior Smallest trigger: `parseOtoolLoadCommands` on otool output with cputype `16777223` (x86_64) and `cmd LC_VERSION_MIN_IPHONEOS`. Main returns `[{"platform":"IPHONEOS",...}]`. dyld (`mach_o/UnsafeHeader.cpp`, `forEachPlatform`) treats IPHONEOS and WATCHOS on x86_64 or i386, and TVOS on x86_64 only, as the simulator ("old sim binary"). Expected: `IOSSIMULATOR`, `WATCHOSSIMULATOR`, `TVOSSIMULATOR`, the names `LC_BUILD_VERSION` codes 7/8/9 already get in the same parser. ## Change and scope - The CPU-type rule from `legacyVersionMinPlatform` moved into an exported `isLegacyVersionMinSimulator(os, cpuType)` in `MachoLoadCommandReader.ts`. The binary reader uses it for its `PLATFORM_*` numbers (same results as before) and the otool parser uses it too, so there's one copy of the rule. - `otool.ts` keeps the header cputype in the load-command state and names simulator images with the existing simulator spellings. Device images keep their current names (`IPHONEOS`, `TVOS`, `WATCHOS`, `MACOSX`), so output for non-simulator images doesn't change. - Not included: renaming the legacy device names to the `LC_BUILD_VERSION` spelling (`IOS`, `MACOS`). That would change output for every legacy image and isn't needed for this bug. Contribution scope: ordinary fix within existing boundaries; no scope decision needed. ## Contract and boundary impact - Semantic owner and earliest changed stage: `collectBuild` in `src/native/parsers/otool.ts`; the rule itself lives in `src/artifacts/apple/MachoLoadCommandReader.ts`. - Contribution scope fit and linked maintainer decision: not applicable (bug fix, #6649). - CLI and MCP/tool-catalog contract: no schema change. `build_metadata.items[].platform` for legacy Intel iOS/tvOS/watchOS images changes from the device name to the simulator name. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none beyond the platform value above. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/providers/native/nativeLoadKinds.golden.test.ts` adds `labels legacy Intel version-minimum images as simulators`: x86_64 and i386 iOS, x86_64 tvOS, x86_64 and i386 watchOS give the simulator names; i386 tvOS, x86_64 MACOSX and arm64 iOS/tvOS/watchOS keep their device names. `withOtoolMachHeader` takes an optional cputype (default stays arm64, so existing fixtures don't change). - Base reproduction: the issue's probe returns `IPHONEOS` on main a281455f. The new test fails on main's source with: ``` - "IOSSIMULATOR", + "IPHONEOS", ``` - User-visible CLI/MCP output: for the issue's input, `build_metadata.items[0].platform` is now `"IOSSIMULATOR"`. - Remaining proof gaps: synthetic otool captures only; I don't have a macOS host to run real otool on an old simulator build. For evidence-bearing changes: - [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 - `npm run test:focused -- tests/boundary/providers/native/nativeLoadKinds.golden.test.ts`: 63 passed (the new test fails on main's source) - `npm run test:focused -- tests/boundary/providers/native/*.test.ts src/artifacts/apple/*.test.ts`: 649 passed, 9 skipped - `npm run check:fast`: typecheck and lint passed - `npm run verify:module-boundaries`: passed ## Compatibility, safety, and release - Breaking changes or migration steps: none; legacy Intel simulator images now get the right platform name. - Real Hopper/Ghidra, browser, or OS coverage: Linux x64, Node 24.18.0, synthetic otool output. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; parsing only. ## Author readiness Human owner: @Sriram-PR - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [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-11-01 21:47:33 +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#7396
No description provided.