Skip to content

fix(ghidra): retain relocation symbol observations - #8531

Merged
morluto merged 4 commits into
mainfrom
codex/ghidra-relocation-symbol
Nov 1, 2026
Merged

morluto merged 4 commits into
mainfrom
codex/ghidra-relocation-symbol

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #8529. Ghidra load-image relocation rows now retain the symbol name recorded by Ghidra, so a relocation to an imported symbol can be attributed without interpreting its analysis-time bytes as a runtime address. Empty strings and nulls are preserved as returned; older Evidence with no recorded symbol stays unrecorded and relocation pages disclose that uncertainty.

Contract and boundary impact

  • Ghidra's relocation table owns the name; the bridge projects Relocation.getSymbolName() into the existing load-image Evidence and its default/selectable relocation pages. This is an existing read-only observation; no maintainer scope decision is required.
  • The Ghidra analysis profile changes to prevent replay of older symbol-free results. Existing exported Evidence remains readable with its original omissions. Independent DOS verification compares only the fields it can attest and does not claim to verify a provider symbol.
  • The output schema and tool description gain the optional nullable field. No target selection, execution, installation, or cleanup authority changes. Generated catalogs remain ignored outputs.

Expected effects: reading caller-selected files and launching Ghidra in its existing ephemeral analysis environment; the target is not executed or modified.

Evidence and regression coverage

On the base, an x86-64 ELF with R_X86_64_64 audit_external produced a Ghidra relocation row with original and analysis-memory bytes but no symbol. A direct Ghidra 12.1.4 headless control returned audit_external from getSymbolName() for the same row; LLVM independently identified the undefined relocation symbol.

On this change, real Ghidra stdio MCP in full and compact profiles returned symbol: "audit_external" in complete and default relocation-page output. A separate relative relocation returned Ghidra's empty string unchanged. The selected pages survived export and import into a fresh target-free server; an authentic old Evidence record remained unrecorded and its page disclosed the unknown. Successful replies validated against the advertised output schemas using Ajv 2020 with strict and format checks disabled. Both source fixture digests and exported bundle digests stayed unchanged; the binaries were not executed. A Ghidra analysis-time address and status do not prove runtime binding.

The focused tests cover provider-boundary parsing of named, empty and null symbols; current and historical page projection; and preservation without overclaiming independent DOS verification. The real DOS verifier checks that each relocation carries a symbol observation and that independently verified DOS loading still passes. A source-built ELF regression in the real Ghidra cross-format lane checks a named external relocation and an unnamed relative relocation through the public CLI. Run alone, it failed on #8509 at the missing name and passed on this branch; the source-owned target stayed unchanged. The full cross-format lane ran the new check but then failed in the pre-existing native-value verifier input-limit issue #8172, before completing the remaining cross-format checks. Windows, other Ghidra versions and autonomous-agent behavior were not tested.

The DOS limitation regression uses the owning guidance constant while separately checking verified status and retained symbol. A temporary wording-only mutation passed; a temporary mutation dropping the symbol failed as expected.

Validation performed

  • npm run test:local -- src/ghidra/GhidraLoadImageValues.test.ts src/ghidra/GhidraRawProfileDigest.test.ts src/application/analysisView/NativeLoadImageViews.test.ts — 64 passed.
  • npm run check:fast, npm run docs:check, changed-file formatting and git diff --check — passed.
  • Real Ghidra 12.1.4/JDK 21 stdio MCP controls on two source-built x86-64 ELFs — passed as described above on macOS arm64.
  • npm run verify:ghidra:dos with Ghidra 12.1.4/JDK 21 on macOS arm64 — passed, including the new real relocation-symbol presence check and verified cleanup.
  • Real named/unnamed ELF CLI regression — passed on this branch and failed on feat(kuna): verify release 1.988 #8509 at the named-symbol assertion. npm run verify:ghidra:cross-format ran that new check, then failed at the existing compare_functions 1,024-element input allowance ([Bug] Ghidra verification sends function Evidence beyond the default MCP input allowance #8172); the full lane did not pass.

Combined cross-format verification

On macOS arm64 with Ghidra 12.1.4 and JDK 21, the full cross-format lane passed in an isolated checkout of prior head d232c43d9 after applying verifier-only changes from #8491 and #8381 and the equivalent structured snapshot assertion from #8536. It exercised seven fixture variants and the new named/unnamed relocation control; process lineage was verified with no remaining descendants and cleanup complete. This combined result does not claim that the clean branch passes the lane without those separate verifier fixes.

Review follow-up

The DOS attestation now states that Ghidra relocation symbol names are retained observations, not independently verified; the independent relocation comparison still excludes the symbol. The verifier's compiler, linker, and CLI subprocesses now use the shared command owner, and its private runtime root is released only after command cleanup succeeds. The test now reports a failed Result directly.

On the follow-up, 62 focused tests and check:fast passed. The supervised named/unnamed real Ghidra CLI regression passed and failed at its intended assertion on the old branch. A forced compiler failure returned an error and left no owned workspace in the controlled temporary parent. The real Ghidra DOS lane passed again with verified cleanup and no remaining descendants. These are one-host controls; the full combined cross-format result below predates this follow-up. CodeQL review for the new command-owner implementation is pending.

Historical snapshot control

A real Ghidra snapshot made on #8509 was rejected on this branch with evidence_integrity_mismatch and a profile-digest mismatch; a fresh analysis returned audit_external. Manually extracting the snapshot's embedded Evidence bundle and importing it into a fresh target-free server preserved the old record exactly, and its relocation page reported the symbol as unrecorded. Manual extraction is a test control, not an advertised snapshot migration feature. Target, snapshot, and extracted bundle digests stayed unchanged.

Compatibility, safety, and release

No runtime binding is inferred. Existing retained observations can omit the new field; new Ghidra profiles differ, so old analysis snapshots do not silently replay the earlier projection. Real provider coverage is limited to the host and fixtures above.

Author readiness

Human owner:

  • 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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge; no blocking code issues remain.

Summary

Retains Ghidra relocation symbol values in Evidence and relocation pages without treating them as runtime addresses.

  • Ghidra relocation rows now retain the symbol names it reports.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Ghidra: getSymbolName()"] --> B["Evidence: retained symbol"]
  B --> C["Relocation pages"]
  B --> D["DOS comparison excludes symbol"]
  E["Historical Evidence: symbol missing"] --> F["Page reports not recorded"]
Loading

Reviews (3) · Last reviewed commit: "test(ghidra): share load verification gu..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraLoadImageValues.ts Resolved
@morluto
morluto marked this pull request as ready for review November 1, 2026 15:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T15:49:52.947754Z 5f35411 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit df25bc8 into main Nov 1, 2026
14 of 18 checks passed
@morluto
morluto deleted the codex/ghidra-relocation-symbol branch November 1, 2026 15:53
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 1, 2026
main moved the real-toolchain lanes section from docs/testing.md to
docs/testing-lanes.md. docs/testing.md takes main's version, the
verify:ghidra:cortex-m paragraph moves to the same place in
docs/testing-lanes.md, and the raw-binary guide links there.

main's load-image observation (morluto#8531) and procedure search (morluto#8520)
revisions change every Ghidra profile digest. With this branch's own
bridge and shared semantics, the merged tree keeps every earlier pin,
so the move is main's alone. The legacy pins take main's own digests at
d3ab0fa, which the merged branch matches for all five loads; the
variant digest is re-pinned. The compatibility test accepts the two new
revisions beside instruction_status and still requires the rest of the
saved profile.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 1, 2026
main's load-image observation (morluto#8531) and procedure search (morluto#8520)
revisions change every Ghidra profile, so this branch's pins move again:
morluto#7951's raw digests and its pre-morluto#7823 snapshot comparison, which now
also sets aside the two revisions, Q10's digests outside the M-profile
ELF lane, and morluto#8464's RISC-V images without an overlap. With this
branch's earlier bridge and shared semantics, every earlier pin holds,
so the move is main's alone. The legacy raw comment now says that these
pins include Change 2's revision, as Q10's does.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 1, 2026
main's load-image observation (morluto#8531) and procedure search (morluto#8520)
revisions change every Ghidra profile digest, so the profiles of images
without an overlap move with main. With this branch's own bridge and
shared semantics, the merged tree keeps the earlier pins, so the move is
main's alone. Both pins take main's own digests at d3ab0fa, which the
merged branch matches.
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 2026
* fix(ghidra): retain relocation symbol observations

* test(ghidra): verify named relocation symbols through CLI

* fix(ghidra): clarify verification and supervise test commands

* test(ghidra): share load verification guidance
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Ghidra load-image relocation omits its recorded symbol name

2 participants