Repository navigation
fix(native): preserve Mach-O install-name whitespace - #4979
Conversation
otool prints dylib install names and rpaths as `<key> %s (offset %u)` with exactly one separator space around the recorded string. The parser trimmed the value and stripped the offset suffix with `\s+`, so a valid install name such as " leading.dylib " became "leading.dylib" in both the dependency inventory and the raw load-command fields. Parse these offset-suffixed string fields by their exact format and strip only the single-space offset suffix. Fixes morluto#3384 Co-Authored-By: Claude Opus 5.5 <[email protected]>
099de26 to
7f66bcc
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryPreserves whitespace in Mach-O install names and rpaths at the owning
Reviews (2) · Last reviewed commit: "chore: merge main into Mach-O install-na..." · Reviewed by Greptile |
|
Welcome to REA, @flyl1u, and thanks for carrying @bharadwajdaya's Mach-O fix forward. The added whitespace cases and CLI/MCP checks help keep dependency names faithful to what the binary records. |
Summary
Fixes #3384. Preserve whitespace in Mach-O install names and rpaths so
inspect-machoreports the recorded dependency identity, including" leading.dylib ", consistently with import sources.Continues the closed, unmerged #3430 by @bharadwajdaya. The original fix is cherry-picked with its author metadata preserved; this PR adapts it to current main and adds broader regressions and real CLI/stdio MCP verification.
Problem and expected behavior
The generic field parser trims the install name and can misread
name version 2.dylibas aname versionkey. The offset-removal expression also consumes trailing whitespace belonging to the name. Parse the exactname/path <value> (offset N)format before generic fields and remove only the final display annotation.Change and scope
Keep the correction at the owning
otoolparser. Preserve upstream linker-option parsing and the exclusion ofLC_ID_DYLIBfrom dependencies. Extend the existing Apple verifier with independent compiled inputs; fixture executables are never run. CR/LF names remain outside this fix.Contract and boundary impact
parseOtoolLoadCommands; consumers use its parsed fields and dependency names directly.otoolload-command output; no new provider or dependency.Expected product effects:
Evidence and regression coverage
b83b9caf4, the expanded native-load test fails 3 cases (spaces, tabs,versionprefix), with 57 passing. With the fix, all 60 pass.(offset 99), a numeric name and an ordinary name; each checks dependency values and rawname/pathfields.otooloutput and import sources, compares public CLI/MCP results, and verifies input bytes remain unchanged.dyld_info's nativeleadingabbreviation. The padded name retains its full import source; the verifier checks both cases explicitly.7f66bccdadfe16abf72d0b3802b58470f3490b6a.Verified field projection from both adapters (other dependency/import items omitted):
{ "dependencies": { "items": [{ "path": " leading.dylib " }] }, "imports": { "items": [{ "name": "_exported_value", "source": " leading.dylib " }] } }Validation performed
npm run check: passed (typecheck, lint, formatting, knip, metadata and architecture guards).npm run check:fast: passed in pre-push.git diff --check: passed.npm run verify:macos-bundle: passed with real Apple utilities and public CLI/stdio MCP on themacos-15runner; both install-name cases retained their bytes and matched across adapters.7f66bccdadfe16abf72d0b3802b58470f3490b6a. This is fork verification; upstream PR workflows still require maintainer approval.Focused test command and local prerequisite
The first attempt stopped before tests because Windows native controls were absent. The matching 6.6.0 controls were restored from upstream CI run 39100876382 at the same base SHA; subsequent baseline and fixed runs completed. These ignored artifacts are not included in the PR.
Compatibility, safety, and release
macos-15CLI/MCP lane passed; no Hopper/Ghidra claim.Merge follow-up: integrated main
15ec8e98d, adapting the install-name verifier to the current advertised MCP-schema helper and named output contract. On macOS with Node 24.18.0, all six focused parser/provider files passed 142 tests andcheck:ci:fastpassed all five tasks.npm run verify:macos-bundlepassed locally with real Apple tools, public CLI and stdio MCP: ordinary and whitespace-padded install names and padded rpaths matched across adapters, original bytes remained unchanged, and temporary DMG cleanup completed. Hosted checks on the merged head are pending.Author readiness
Human owner: @flyl1u
Before merge
type(scope): outcome.Co-authored-by: Bhaaraadwaj [email protected]