Repository navigation
feat(native): expose typed incoming references at exact addresses - #1715
Conversation
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. |
|
TL;DR: I ran PR 1715 against real Ghidra 12.1.4 on Linux with a small C program. Every call, pointer, read and write I expected came back with the right type and source address. Two things differ from my objdump list: Ghidra types a tail jump as a call, and it adds one computed call. ResultsI built a small x86-64 ELF with gcc. I wrote the expected references from
In the table, Before the PR, base
Base and head agree on every other field, over MCP and the CLI. The three changed test files pass on Node 22, 24 and 26. An old snapshot is refused on head. I also put a data pointer in the middle of an instruction, in a second build. Not run
Thanks, bugstan, for the PR. Details
fixture.cvolatile int g_counter = 5;
typedef int (*fn_t)(int);
__attribute__((noinline)) int target_fn(int x) { return x * 3 + (int)g_counter * 0 + 1; }
__attribute__((noinline)) int via_call(int a) { int r = target_fn(a); return r + 1; }
fn_t volatile g_fnptr = target_fn;
__attribute__((noinline)) int read_global(void) { return g_counter; }
__attribute__((noinline)) void write_global(int v) { g_counter = v; }
__attribute__((noinline)) int jump_into(int a) { return target_fn(a + 7); }
int main(int argc, char **argv) {
(void)argv;
int r = via_call(argc);
r += read_global();
write_global(r);
r += jump_into(r);
r += g_fnptr(r);
return r;
}Built with Commandsgcc -O2 -fno-pie -no-pie -fno-asynchronous-unwind-tables -fcf-protection=none -o fixture fixture.c
objdump -d --no-show-raw-insn -M intel fixture
readelf -S -h -x .data fixture
# head and base, one MCP stdio session each:
# open_binary {path, provider_id: "ghidra"}
# inspect_native_instruction {address} and xrefs {address}, per address
# resolve_native_call_targets {address}, then close_binary
# CLI, one run per address
node <rea-root>/scripts/rea.mjs inspect-native-instruction fixture 0x400480 --provider ghidra --format json
node <rea-root>/scripts/rea.mjs xrefs fixture 0x400480 --provider ghidra --format json
# snapshot test: on base, open_binary, inspect_native_instruction, then
# close_binary {snapshot_path}; on head, open_binary {path, provider_id, snapshot_path}
# tests, once per Node
node node_modules/vitest/vitest.mjs run src/ghidra/GhidraFunctionValues.test.ts \
src/ghidra/GhidraSnapshotCache.test.ts tests/boundary/mcp/ghidraCompactReferencesMcp.test.tsExact error textOld snapshot opened on head, Address The other four edge addresses raise no error. They return a normal result with the status shown in the table. Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thank you @bugstan for completing typed incoming references! Preserving exact addresses, access kinds, primary status, and provenance makes the compact inspection much more useful, and the unavailable-versus-empty distinction and snapshot versioning keep the evidence semantics clear. I reviewed the change with no actionable findings; all 53 focused tests passed and CI is green. Thanks also @CassieFox23 for the independent Linux verification. Squash-merging this now. |
Closes #1245. Completes the typed incoming-reference portion left open after #1438.
inspect_native_instructionnow returnsincoming_referencesfor the exact queried code or data address. Ghidra preserves each source/target, operand index, access kind, primary status and provider/source provenance, using deterministic address ordering and excluding synthetic entry-point references. Existing outgoingreferencesand bare-addressxrefskeep their meanings. Call-target resolution skips the incoming scan.An empty array means the address was examined and no references were found; omitted/null coverage remains unavailable for historical Evidence or other providers. The Ghidra profile versions the new coverage, so older snapshots must be rebuilt instead of replaying results without it. Analyzer references remain static observations, not proof of literal addressing or runtime access.
Validation on Windows 11 x64 with Node 24.18.0 and npm 11.16.0:
npm run check,npm run check:fast,npm run docs:check, andnpm run verify:test-discoverypass. The full format check used an LF checkout on NTFS; the original Windows clone uses CRLF.verifyGhidraCompactReferencesthrough a focused real stdio MCP/CLI harness. This covers DATA/READ/WRITE, non-primary analyzer references, incoming/outgoing/full-dossier agreement, xrefs ordering, entry-point filtering, empty and targetless cases, CLI/MCP parity, and completed runtime cleanup.Existing verification limitations: the general Windows verifier stops at its capability-list assertion because it excludes only
annotate_native_functionwhile the read-only bridge also omits naming mutations. A broader provider test run passes 39/40; its unchanged test expecting unavailable Windows native controls fails when the built addon is present. Neither unrelated assertion was changed. The complete deterministic suite and real Linux/macOS providers were not run.