Repository navigation
feat(ghidra): report computed branches without a recovered jump table - #2977
RishTheFish21 wants to merge 51 commits into
Conversation
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. |
[Medium impact] The reviewed changes appear safe to merge, with no new actionable issues found. SummaryAdds Ghidra observations for computed jumps without recovered jump tables.
Validation was source-only; no tests were run. Supersession could not be checked because GitHub access required authentication. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Listing[Ghidra function instructions] --> Filter[Keep computed jumps without recovered tables]
Comments[Typed decompiler comments] --> Attribution[Match warning sources and discount saved copies]
Filter --> Inventory[Bounded branch inventory with evidence]
Attribution --> Inventory
Inventory --> Schemas[Validate addresses and preserve optional fields]
Schemas --> Inspection[Report per-site unknowns]
Schemas --> Page[Page retained sites and report omissions]
Reviews (15) · Last reviewed commit: "merge(main): refresh computed-branch int..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26fd63c396
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| : ["structured-boundary-types", "jump-table-data-mapping"]; | ||
| const unsupportedBranches = !boundary.available | ||
| ? ["structured-boundary-types", "jump-table-data-mapping"] | ||
| : (boundary.unresolved_indirect_branches ?? []).length > 0 |
There was a problem hiding this comment.
Preserve omission as an uninspected branch facet
When an available boundary comes from an older cached dossier or another provider that omits the new exact-optional field, this ?? [] reports no indirect-branch-target-recovery, and availableResidualUnknowns similarly emits no branch unknown. The schema explicitly defines omission as meaning that the provider did not inspect indirect branches, so this conflates “uninspected” with an inspected empty inventory and presents incomplete analysis as complete; handle omission separately from [].
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed: an absent unresolved_indirect_branches now reports indirect-branch-inventory in unsupported_branches plus a residual unknown; only an explicit empty array means none were found. Covered by new tests.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 523cad54fc
ℹ️ 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".
|
TL;DR: I ran this PR on Linux x64 with real Ghidra 12.1.4, and it works. The computed jump now shows up with the decompiler warning, and the base says nothing. Both named unit files pass on Node 22, 24 and 26. ResultsI tested head 523cad5 against its base 2895a18, on the PR's AArch64 fixture. The base is the head with the four changed source files put back.
The functions are
The 2 base failures are expected, because the old schema rejects the new field. The GhidraFunctionValues case likely passes on base for that same reason, so it may not tell old from new. I did not check that one. Ghidra said "Treating indirect jump as call" for both functions. I saw no return case. The analysis profile digest is the same on base and head, as the open Codex note says. Not runEdit (2026-10-13): The retest on fb7764564 covers the snapshot item below. The rest is still not run.
Thanks, RishTheFish21, for the fix. Thanks, morluto, for the stricter check. This is the gap I reported on #487. Test setup
Commandsclang --target=aarch64-linux-gnu -c tests/conformance/ghidra/indirect-branches.S -o indirect-branches-elf.o
rea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100000 --provider ghidra --json
rea function indirect-branches-elf.o rea_indirect_tail_call --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100038 --provider ghidra --json
node scripts/run-development-tests.mjs focused src/application/native/NativeApiInspection.test.ts
node scripts/run-development-tests.mjs focused src/ghidra/GhidraFunctionValues.test.tsEvery command exited 0. Only the base run of the NativeApiInspection file exited 1. The test script is the one behind Decompiler output on both treesGhidra printed this before the PR too. The PR carries the warning into the REA output. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@CassieFox23 Thanks for running it on Linux. Two of your notes led to changes in the latest push:
Also from review: an absent inventory now reports |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb77645644
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| private static final Pattern DECOMPILER_JUMP_TABLE_FAILURE = Pattern.compile( | ||
| "Could not recover jumptable at (?:([A-Za-z_][A-Za-z0-9_]*):+)?(?:0x)?([0-9A-Fa-f]+)[^\\r\\n*]*" |
There was a problem hiding this comment.
Parse segmented warning addresses before branch matching
The new space-aware key still parses only one hexadecimal run, so when a supported DOS COM/MZ function gets a warning rendered with Ghidra's segmented coordinate (for example 1000:010c), group 2 is only 1000 and :010c is consumed as suffix text. warningSpaceKey then stores offset 0x1000, while the listing address uses the linear SegmentedAddress.getOffset() (ReaGhidraPrepareCom.java:14 constructs 1000:0100, which docs/ghidra-dos.md:69 maps to 0x10100), so the warning never attaches and the branch is falsely labeled no_jump_table_warning without its warning evidence; parse and canonicalize the full coordinate with Ghidra's address factory instead.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
| ? [] | ||
| : ["structured-boundary-types", "jump-table-data-mapping"]; | ||
| const unsupportedBranches = !boundary.available | ||
| ? ["structured-boundary-types", "jump-table-data-mapping"] |
There was a problem hiding this comment.
Report inventory gaps when the boundary is unavailable
When dossier.native_api is null, as emitted by Hopper (bridge/hopper_bridge.py:719) and IDA (src/ida/IdaOperationRunner.ts:714), unavailableBoundary() means the provider exposed no branch inventory, but this arm still returns only the two legacy unsupported facets and later copies the legacy residuals unchanged. The new undefined check runs only for an available boundary, so inspect_native_api emits neither indirect-branch-inventory nor an indirect-branch residual for these uninspected providers; include that uncertainty in the null/unavailable projection too.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
TL;DR: I re-tested this PR at fb77645 on Linux x64 with real Ghidra 12.1.4. Old saved snapshots are now refused instead of replayed. The earlier CLI results and both named unit files still hold. Edit: I retested at b4fd1de. The results are here. ResultsBase is 2895a18 (#2943), the old head is 523cad5, and the new head is fb77645. I saved
The first row is the gap this push closes. The old head finds the branch on a fresh run, but its replay of a base snapshot hid it. The profile digest began The CLI results hold. Both functions still get one entry, at
The push adds one test to each file. My first run had 8 and 51 tests. Still not run
Thanks, RishTheFish21, for the quick fix. Test setup
Profile digests
The new profile carries
Raw output of a refused load{"error":"Analysis failed","code":"evidence_integrity_mismatch","category":"integrity_mismatch","message":"Analysis snapshot profile_mismatch: target, provider, or analysis profile does not match the requested binary","retryable":false,"remediation":{"action":"Run analysis without this snapshot, then save a fresh snapshot using the intended artifact, provider, and analysis profile."},"details":{"reason":"Analysis snapshot profile_mismatch: target, provider, or analysis profile does not match the requested binary"}}Commandsrea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot base.json
rea inspect-native-api indirect-branches-elf.o 0x100000 --provider ghidra --json --snapshot base.json
rea decompile indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot base.json
cp base.json copy.json
rea function indirect-branches-elf.o rea_computed_branch --provider ghidra --json --snapshot copy.json
rea function indirect-branches-elf.o rea_indirect_tail_call --provider ghidra --json
rea inspect-native-api indirect-branches-elf.o 0x100038 --provider ghidra --json
node scripts/run-development-tests.mjs focused src/application/native/NativeApiInspection.test.ts
node scripts/run-development-tests.mjs focused src/ghidra/GhidraFunctionValues.test.tsI made a fresh copy of the snapshot before each load, because 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Hey @RishTheFish21, I wanted to reach out about contributing to your indirect-branch recovery work. I previously contributed REA's generic MIPS and PSP/Allegrex support through #1362 and #1599. I'm working toward more robust PSP reverse engineering, and your changes address an important problem: preserving control-flow uncertainty when Ghidra can't recover the original dispatch. I saw the existing AArch64 verification and the independent Linux testing from @CassieFox23, as well as the newer review findings. I don't want to duplicate work you're already handling. One thing I could contribute is a source-owned Allegrex fixture covering a computed I still need to restore the appropriate PSP testing environment, so this is a proposed regression rather than a completed result. Would that be helpful within #2977, or would you prefer a separate PSP-specific follow-up? I'm interested in collaborating on your existing implementation rather than developing a competing one. Status update (October 23, 2026): The PSP/Allegrex fixture was subsequently validated against real Ghidra and remains a separate follow-up, as requested. For this PR's own saved-warning attribution issue, I have now shared a focused regression commit. That new regression has not yet had a real-Ghidra run; the original collaboration offer and earlier status above are preserved for context. |
|
Following my collaboration offer and the reported unavailable-boundary inventory gap, I’ve prepared a focused correction for PR #2977. The earlier fix made Hopper/IDA’s unavailable boundary report the missing indirect-branch inventory. A persisted CLI workflow snapshot could still return an older The regression used a persisted, authenticated old-profile snapshot. Before the revision, it returned the legacy result without the inventory unknown. Afterward, the CLI runs the workflow, preserves the historical Evidence, emits the unknown, and can replay a fresh result. A linked source-Evidence control also passed. The profile controls for The contribution is on my fork at Validation used Node 22.23.1 and npm 10.9.8; the package pins npm 11.16.0. The persisted CLI test uses REA’s fixture provider. I did not run real Ghidra or PSP tests. Please feel free to incorporate both commits into your existing PR. I’d also welcome your guidance on whether a later source-owned Allegrex regression should live in #2977 or a separate follow-up. |
|
CI-fix track: none of the failures came from this PR. The Source tests job failed in |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thanks @jaelliot, both commits are in. cherry-picked onto the current head with your authorship. Good catch on the second cache layer. On the Allegrex fixture, I'd prefer a separate PSP-specific follow-up. That keeps this PR focused on the AArch64 evidence it already has, and lets your fixture land with its own real-Ghidra results once your PSP environment is back. It would be a useful second architecture for this, since a computed |
|
Hey @RishTheFish21, following your request to keep the Allegrex regression separate from #2977, I've now verified the source-owned PSP control-flow fixture against real Ghidra 12.1.3 + ghidra-allegrex v21.4 + PSPDEV v20261001 on Linux. Fixture/verifier branch in my fork | successful real-Ghidra CI run The run is based on REA main Observed in real Ghidra: both register-based This is not a test of #2977's unmerged branch or proof that its new decompiler-outcome labels work for Allegrex. The older #2977 head still predates main's complete GNU MIPS ABI inspection and refused the present PSP baseline before its extension path ran, so I did not bypass admission or force-merge the branches. I'll keep the PSP follow-up independent as you requested. Would you prefer that I wait for #2977 to merge before proposing the separate PSP regression PR? I can then make the test assert actual unresolved-branch Evidence and its snapshot semantics against the integrated source, rather than rely on assumed output. |
…t-main candidate
…ature overlay Retain the existing morluto#2977 integration and pinned fork workflow. Update only the PSP indirect-branch verifier to the exact d7360ed source for cleanup, missing-inspection, listing-target, and replay-provenance checks.
Use the exact 1dc5521 verifier with the existing morluto#2977 integration and pinned PSP/Ghidra workflow. Preserve the prior failed qualification as evidence of the raw-versus-qualified marker mismatch.
|
@RishTheFish21 — following up with a concrete handoff/decision for the canonical #2977 (not a competing PR). I rechecked upstream The existing fork-only candidate One remaining independent gate: your original upstream CI failed a 30-second macOS |
|
Hey @RishTheFish21, thanks for the PR! This addition looks good to me. What's left: it has merge conflicts with main in |
Expose native_api.unresolved_indirect_branches as a bounded native view facet, so the retained inventory can be read a page at a time instead of only inside the native_api singleton. Sites beyond the provider's inventory bound stay unknown on every page, an uninspected inventory reports "not recorded", and an unavailable native_api keeps its reason.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thanks @morluto. Here's where each item stands:
Local validation at |
… fails Report incomplete supervisor cleanup and a failed workspace removal alongside the probe's own failure instead of replacing it, as verifyTarget already does, so the original Ghidra assertion and output survive.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Keeps both sides in knip, the conformance README, the Ghidra and workflow profiles, and snapshot admission; morluto#2977's inspect_native_api revision now sits in main's workflowAnalysisProfileParameters. The raw profile digests are repinned.
|
Merged current main ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7f2ba2815
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| unresolved_indirect_branches: dossier.native_api?.available | ||
| ? dossier.native_api.unresolved_indirect_branches | ||
| : undefined, |
There was a problem hiding this comment.
Preserve branch coverage in the default summary
When analyze_function uses its default detail: summary, this new collection is only wired into nativeRows: neither parentFields nor summarizeDossier reports an available boundary whose inventory is absent or whose unresolved_indirect_branches_omitted count is positive. Consequently an uninspected inventory and a Ghidra function that hit the 256-site cap both produce a compact result without the corresponding coverage unknown/count (it appears only if the caller already knows to request this facet), so propagate the nested inventory coverage state into the summary's counts or unknowns.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
|
TL;DR: On head f7f2ba2, the PR's 11 test files passed on all three Node versions. The Results
Not run
Test setupCommandsnpm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/application/WorkflowEvidence.test.ts src/application/binary/AnalysisSnapshotCache.test.ts src/application/native/NativeApiInspection.test.ts src/domain/analysisView/analysisView.test.ts src/ghidra/GhidraFunctionValues.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/ghidra/GhidraRawProfileDigest.test.ts src/ghidra/GhidraSnapshotCache.test.ts tests/boundary/filesystem/directAnalysisSnapshotReplay.test.ts tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts tests/boundary/mcp/ghidraNativeApiMcp.test.ts🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
…gests Main's morluto#9566 fixes the sourcePublicationComposed failure in test shard 6. The raw profile digests changed again; both are repinned, and this PR's indirect_branch_inventory assertion is kept.
Main's morluto#9706 makes this MCP test create two Evidence records instead of three, so the automatic unknown counts drop from 6 to 4 (two per record). The raw profile digests changed again and are repinned; the profile assertion keeps both main's native_value_flow_projection and this PR's indirect_branch_inventory.
Resolves one import conflict in the direct snapshot replay test: keeps main's verifier cleanup import and this PR's createEvidenceBundle import.
|
@morluto This has been open since Oct 13, so a quick nudge. Per your Oct 18 backlog note, the conflicts are resolved and the head ( |
|
@RishTheFish21, I prepared a merge candidate for Typecheck, lint, formatting and the workflow revision checks passed. Focused suites had 207 passes and two skips. One Swift literal pagination fixture failed identically on a pristine copy of main Update for review at |
|
Thank you for this contribution! The computed-branch reporting work has already landed on |
|
Thanks @morluto. I think this was closed by mistake: Could you reopen this? If you'd rather have a fresh PR rebased onto current |
Summary
Part of #487 (second of the steps proposed there; the first was #1592). When Ghidra cannot recover a jump table for a computed
br, its decompiler rewrites the branch as a call or return (FlowInfo::truncateIndirectJump), so nothing reached REA's output:jump_tablesandunsupported_branchesstayed empty and the dossier read as complete. This is the gap @CassieFox23 reported for the RenderScript blur kernels.This PR reports those sites in a new optional field,
native_api.unresolved_indirect_branches, and surfaces each one as a residual unknown ininspect_native_api.Problem and expected behavior
Before: a function whose only dispatch is an unbounded computed jump (
adr x8, …; add x8, x8, x0, lsl #3; br x8) producesjump_tables: [],unsupported_branches: [], and no residual unknown.After, for the same function:
unresolved_indirect_branches: [{ branch_address, decompiler_outcome: "jump_table_recovery_failed", listing_targets: [], evidence: [...] }], with Ghidra's warning ("Could not recover jumptable at … Too many branches") retained as evidenceunsupported_branches: ["indirect-branch-target-recovery"]Change and scope
ReaGhidraBridge.java): every listing instruction in the function body whose flow type is a computed jump (not a call or terminator), and whose address is not a recoveredJumpTableswitch, is reported.decompiler_outcomeisjump_table_recovery_failedwhen the decompiler's pseudocode contains "Could not recover jumptable at ", otherwiseno_jump_table_warning.listing_targetsare the listing's flow references (no case values implied).nativeApiBoundary.ts): newunresolved_indirect_branchesfield usingexactOptional(): absent means the provider did not inspect indirect branches, so Hopper/IDA output and older snapshots parse unchanged. New evidence kindindirect-branch.NativeApiInspection.ts): one residual unknown per site andindirect-branch-target-recoveryinunsupported_branches.Deliberately not attempted: telling a dispatch apart from an indirect tail call. On real Ghidra 12.1.4 both produce the same recovery failure (see Validation), so REA reports the uncertainty instead of guessing. Not included: the decompiler-failure handling from #487 (a separate follow-up), and sites in regions where Ghidra created no function.
Contract and boundary impact
analyze_function/inspect_native_apioutput gains the optionalunresolved_indirect_branchesfield, the evidence kindindirect-branch, and theunsupported_branchesvalueindirect-branch-target-recovery. Existing fields are unchanged.docs/public/product-catalog.json), package, or installation impact: output schemas regenerate in CI; no tracked metadata changes.Evidence and regression coverage
NativeApiInspection.test.ts: residual unknowns andunsupported_branchesfor both outcomes; empty or absent inventory adds nothing; a branch without evidence is rejected.GhidraFunctionValues.test.ts: a non-canonical branch address is rejected.tests/conformance/ghidra/indirect-branches.S(unbounded computed jump plus an indirect tail call) in theaarch64-jump-tablelane, as ELF and, on arm64 hosts, Mach-O. The lane asserts the computed jump is reported and not mistaken for a jump table, and records the tail call's classification.mainthe field doesn't exist, so the fixture's computed jump leaves no trace in the dossier.librenderscript-toolkit.sofrom the issue thread; no Linux run.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/application/native/NativeApiInspection.test.ts src/ghidra/GhidraFunctionValues.test.ts: passednpm run check:fast: passednpm run lint,npm run knip: passednpm run docs:check: passednpm run verify:ghidra:aarch64-jump-tableon an Apple Silicon Mac (Ghidra 12.1.4, JDK 21):ok: true.jump_table_recovery_failedwith the decompiler warning, on ELF (0x10000c) and Mach-O (0xc).jump_table_recovery_failed("Could not recover jumptable at … Too many branches") on both formats.relative-*switch fixtures passed, including the new "not unresolved" check.Note on that run: on current
mainthe lane stops early in the host-native native-value check, wherecompare_functionsof a function against itself returnsunknowninstead ofunchanged. Reproduced onmainwithout this PR. Thecommentsfacet is empty with no declared coverage, andcallslacks relationship coverage, which looks related to #2450 (b17487f4). I skipped that one assertion locally to reach the fixtures this PR adds, and will report it separately.Compatibility, safety, and release
Review checklist
type(scope): outcome.Author readiness
Human owner: @RishTheFish21