Repository navigation
feat(apple): resolve joined IPS frames to LC_SYMTAB symbols - #10073
iamcipherdev wants to merge 1 commit into
Conversation
Joined frames now report the containing symbol-table symbol for their static address (table name, runtime spelling, symbol address, byte offset) when the joined Mach-O slice carries LC_SYMTAB. Slices without a usable table report symbol null with a join limitation instead. Closes morluto#4297
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8599860b16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const start = strtab + strx; | ||
| const end = bytes.indexOf(0, start); | ||
| if (end === -1 || end >= strtab + strsize) return null; | ||
| if (end - start > MAX_SYMBOL_NAME_BYTES) return null; |
There was a problem hiding this comment.
Preserve unknowns for overlong symbol names
When a valid N_SECT name is longer than 1,024 bytes, symbolName returns null and readAppleIpsJoinSymbols silently drops the entry. Frames between that symbol and the next retained one then inherit an older preceding symbol in the same segment, producing a false name and offset instead of an unknown result; surface this per-entry incompleteness or prevent lookup from crossing the skipped entry.
AGENTS.md reference: AGENTS.md:L97-L97
Useful? React with 👍 / 👎.
| low = middle + 1; | ||
| } | ||
| } | ||
| for (let index = low - 1; index >= 0; index -= 1) { |
There was a problem hiding this comment.
Bound symbol lookup to the target segment
For a joined frame whose derived address is in a segment with no symbols, such as __DATA after all __TEXT symbols, this global backward scan examines every lower-valued symbol for every frame. The admitted 1,048,576-entry symbol cap and 65,536-frame cap allow about 68 billion iterations on a bounded but crafted join, making inspection effectively hang; start the search at the segment's address range or index symbols by segment.
AGENTS.md reference: AGENTS.md:L57-L58
Useful? React with 👍 / 👎.
Fixes #4297
Summary
A joined
.ipsframe now reports the containing symbol-table symbol for its static address, the last piece of #4297 the maintainer kept open after #6511 (offline inspection) and #9570 (UUID/architecture join withstatic_address). The report's own printed symbol names stay recorded claims; the joined frame'ssymbolis derived from the joined artifact's ownLC_SYMTAB.Problem and expected behavior
inspect_apple_ipswithjoin_pathjoined frames to a Mach-O slice byLC_UUIDand architecture and derivedstatic_address, but stopped there: the analyst still had to runatosby hand to learn which function faulted. For the issue's fixture A, frame 0 should resolve torea_fixture_faultand frame 1 tomainat the static addressesatosresolves to the same functions.Change and scope
src/native/apple/AppleIpsSymbolTable.tsreads one slice'sLC_SYMTAB(nlist/nlist_64plus string table, reusing the existingreadMachoSymtabCommandandmachoRuntimeSymbolName) and resolves the nearest precedingN_SECTsymbol in the same segment as the static address, the same ruleatosapplies. DWARF debug info is never consulted.symbol: { name, runtime_name, address, offset } | nullin the join schema; unjoined frames reportsymbol: null. A slice with noLC_SYMTAB, or an unusable table (out-of-slice bounds, over the 1,048,576-entry ceiling), keeps the join working and records why injoin.limitations. Malformed tables fail the symbol step only, never the report.readSliceSegmentso the slice walk stays readable; the report limitation text anddocs/apple-ips.mdnow describe symbol resolution, and the new integers are charged to the integer-text allowance.atosor any external tool.Follow the contribution scope. This is a read-only extension of an existing static local-file inspection; no new provider, target execution, or scope decision is involved. The maintainer kept #4297 open for exactly the join and the function/symbol resolution.
Contract and boundary impact
AppleIpsMachOJoinslice identity; the new symbol-table module ownsLC_SYMTABinterpretation and its consumers read its parsed facts.symbolmember; unjoined frames and no-join reports are unchanged.LC_SYMTAB; FAT containers resolve per slice. No binary linking or Ghidra seeds.docs/public/product-catalog.json), package, or installation impact: none; CI generates catalogs.Expected effects:
Evidence and regression coverage
tests/boundary/filesystem/appleIpsJoin.test.ts(64-bit resolution incl. offset and runtime name, nearest-preceding symbol for an inlined frame, no-LC_SYMTABlimitation, malformed-table limitation, 32-bit slice) plus updated exact-shape expectations for joined/unjoined frames; domain limitation text updated.30f96aef), the new/updated tests fail exactly as expected — 6 failed, 28 passed — because joined frames carry nosymbolmember there. On this branch all 34 pass.{ "static_address": { "decimal": "4294968120", "hex": "0x100000338" }, "symbol": { "name": "_rea_fixture_fault", "runtime_name": "rea_fixture_fault", "address": { "decimal": "4294968108", "hex": "0x10000032c" }, "offset": { "decimal": "12", "hex": "0xc" } } }_mainat offset 40; a frame with no symbol-table entry of its own resolves to the nearest preceding symbol (_main, offset 140).Boundary regressions covered: parser/admission (symbol-table bounds, truncated command, out-of-slice tables), malformed-input and capacity (entry ceiling, name-length cap). No lifecycle stage is added, so no lifecycle regressions apply.
For evidence-bearing changes:
Validation performed
npm run test:focused -- tests/boundary/filesystem/appleIpsJoin.test.ts— 34 passed (30 existing + 4 new).npm run test:focused -- tests/boundary/filesystem/appleIps.test.ts tests/acceptance/appleIpsCli.test.ts tests/acceptance/appleIpsJoinFailureCli.test.ts tests/boundary/mcp/appleIpsMcp.test.ts src/domain/native/appleIps.test.ts src/native/apple/AppleIpsParser.test.ts src/native/apple/AppleIpsProvider.test.ts src/application/binaryDiagnostics/AppleIpsService.test.ts— 8 files, 99 passed.npm run check:fast— typecheck and lint passed (only the 2 pre-existing warnings remain).npm run verify:test-discovery— all 3385 test files discovered exactly once.npm run docs:check— 9 passed.Compatibility, safety, and release
Author readiness
Human owner: @iamcipherdev
Before merge
type(scope): outcome.