Repository navigation
fix(ghidra): stage sibling dSYM beside target snapshot for DWARF analysis - #10768
cainiao1992 wants to merge 1 commit into
Conversation
Codex Review Summary: ❌ FailedThis 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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The change affects Ghidra analysis and checkpoint selection for targets with sibling dSYM files. Fix default-profile identity before merging so saved REA answers cannot hide added or changed debug symbols. Findings
Fix with agent prompt### Issue 1
src/ghidra/GhidraTargetSnapshot.ts:134-140
Without checkpoint mode, staging a dSYM changes Ghidra's symbols but leaves the analysis profile unchanged. Save a REA analysis snapshot without the companion, then add it and reopen with that snapshot: the target/profile checks still pass, so symbol-dependent reads can return old names and types without running Ghidra.
Bind the companion digest into the default analysis profile too, and check the staged digest before launch. The repository requires cache keys to cover inputs that affect results.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryStages sibling dSYM bytes beside the renamed target and gives companion-bearing checkpoints their own content-bound keys.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Selected target] --> B{Checkpoint mode?}
B -->|Yes| C[Hash companion into checkpoint key]
B -->|No| D[Keep existing analysis profile]
C --> E[Stage target and companion]
E --> F[Check staged digest before launch]
D --> G[Look up saved REA answers]
G -->|Matching target and profile| H[Replay old answer]
Reviews (4) · Last reviewed commit: "fix(ghidra): keep dSYM key verification ..." · Reviewed by Greptile |
5f77805 to
f2b8c26
Compare
940bd63 to
dbefbc2
Compare
|
Thanks @cainiao1992! Most of this has since landed on main: #12081 made Ghidra 12.2 with JDK 25 the verified build and dropped 12.1.x, and Homebrew Ghidra discovery is already in |
dbefbc2 to
03d73cd
Compare
|
@morluto Done — this PR is now only the dSYM companion staging change, rebased on current What remains:
Verified on macOS arm64 with real Ghidra 12.2 / JDK 25: a stripped arm64 Mach-O cannot resolve Thanks! |
|
@cainiao1992 thanks for the PR — there is 1 open review thread here:
Could you address or reply to this? Once it's resolved and CI is green we can take another look. |
63612ef to
b50d72a
Compare
…ysis Xcode 17 clang emits all DWARF into a sibling <name>.dSYM bundle while the Mach-O keeps no __debug_info. Ghidra's DWARFAnalyzer only discovers a bundle named after the staged executable, so a staged target-<hash>.bin lost every DWARF symbol and procedures resolved only by raw Mach-O names. Stage the caller-selected sibling dSYM DWARF member beside the snapshot under the staged name with the existing cancellable chunked-copy path, verifying read coverage and source identity. Absent, malformed, or unreadable companions keep the snapshot's unknown-symbol semantics; cancellation propagates. When a companion stages, commit its content digest in the analysis profile and use that profile in the checkpoint key. Analysis snapshots, Evidence, and checkpoints therefore cannot replay results produced without the companion, and a changed dSYM starts a separate analysis. Targets without a companion keep the established profile and checkpoint identity. Before launch, hash the staged companion and compare it with the profile commitment in both checkpoint and ephemeral modes. A dSYM that appears, disappears, or changes after profile resolution refuses startup and asks the caller to reopen the target instead of analyzing under a different identity.
dc44fa7 to
dbf9de4
Compare
Summary
Stage the caller-selected sibling
.dSYMbeside the Ghidra target snapshot so Xcode 17 clang DWARF is visible to Ghidra, and bind that companion to the analysis profile and checkpoint identity.createGhidraTargetSnapshotcopies<source>.dSYM/Contents/Resources/DWARF/<source>to the staged name using the existing cancellable chunked-copy path, then verifies read coverage and source identity. An unstable companion removes the partial bundle and keeps the snapshot's no-companion semantics, matching the digest probe; absent, malformed, or unreadable companions stay optional and cancellation propagates.GhidraProvidercommits its digest in the default analysis profile. Analysis snapshot bindings, Evidence, and checkpoint identity therefore cannot replay results built without those symbols; adding or changing a dSYM starts a separate analysis instead of restoring a Program built without them, and never overwrites the saved Program. Targets without a companion keep the established profile and checkpoint identity.GhidraClienthashes the staged companion and compares it with the profile commitment before launch in both checkpoint and ephemeral modes. A mismatch refuses startup and asks the caller to reopen the target.Per maintainer request, this PR now contains only the dSYM change and is rebased on current
main; the 12.2/JDK 25 and Homebrew work already landed separately.Problem and expected behavior
Xcode 17 clang emits all DWARF into a sibling
.dSYMwhile the Mach-O keeps no debug sections. Ghidra's DWARF analyzer only discovers a bundle named after the staged executable, so a stagedtarget-<hash>.binlost every DWARF symbol and procedures resolved only by raw Mach-O names. After this change, a matching companion stages under the staged name and its symbols participate in the analysis.Change and scope
Follow the contribution scope. Not applicable: this uses existing provider and owned-runtime boundaries. It adds no target authority, injection, mutation, or protection-recovery capability.
The profile and checkpoint identity change is deliberately additive for no-companion targets so existing profiles, manifests, snapshots, and Evidence remain valid. A companion changes which analysis inputs produced the Program, so it receives its own profile digest and key rather than reusing or overwriting incompatible saved results.
Contract and boundary impact
GhidraCompanionDsymowns the digest probe and staging path;GhidraProvidercommits the digest in the analysis profile;GhidraCheckpointconsumes the profile digest in the storage key;GhidraClientverifies the staged bytes against the profile commitment.companion_dsym_sha256parameter only when a companion stages. Snapshot and Evidence bindings that reference a companion-bearing profile therefore differ, while no-companion profiles, checkpoints,owned_checkpoint, and Evidence remain unchanged. The checkpoint manifest stays at version 2.Expected effects:
Evidence and regression coverage
GhidraTargetSnapshot.test.tscovers renamed staging, absent/malformed companions, staging cleanup, a source rewritten mid-copy, cancellation during copy, and cancellation while hashing the digest;GhidraCheckpoint.test.tscovers unchanged identity without a companion, a separate checkpoint when the profile commits one, and content-bound identity;GhidraProvider.behavior.test.tsproves the dSYM digest changes the profile and invalidates its snapshot binding;ghidraCheckpointLifecycle.test.tscovers companion commitment and late addition in checkpoint and default modes.procedure_not_found: rea_checkpoint_leafwhen the staged Mach-O lost DWARF, and restored bare names and struct types after placing a renamed dSYM beside the snapshot. That real-provider observation was made on the earlier branch and was not re-run in this environment.verify:ghidra:checkpointsrun here because no real Ghidra/JDK is available in this environment.For boundary fixes, this adds profile-binding and checkpoint-identity regressions at the staging, profile, storage, and lifecycle owners; real-provider checkpoint replay remains a gap.
For evidence-bearing changes:
Validation performed
npm run test:local -- src/ghidra/GhidraTargetSnapshot.test.ts src/ghidra/GhidraCheckpoint.test.ts— 28 passed.npx vitest run src/ghidra— 1423 passed, 1 skipped.npm run test:focused -- tests/boundary/providers/ghidra/ghidraClient.test.ts tests/boundary/providers/ghidra/ghidraTargetSnapshot.test.ts tests/boundary/providers/ghidra/ghidraCheckpointLifecycle.test.ts— 127 passed.npm run check:fast— passed (typecheck, lint, architecture guards).npm run docs:check— passed.verify:ghidra:checkpoints(no real Ghidra/JDK in this environment).Compatibility, safety, and release
Author readiness
Human owner: @cainiao1992
Before merge
type(scope): outcome.