Skip to content

fix(providers): mark callee coverage partial at computed call sites - #8340

Merged
morluto merged 4 commits into
mainfrom
fix/8277-call-path-computed-target-uncertainty
Nov 9, 2026
Merged

morluto merged 4 commits into
mainfrom
fix/8277-call-path-computed-target-uncertainty

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #8277. Computed-call observations do not establish all possible targets or callers. Keep observed relationship inventory completeness separate from discovery uncertainty, so negative reachability and comparison results retain the relevant unknowns.

Ghidra preserves recorded computed-call targets and explicitly qualifies additional callee/caller discovery. Both IDA callee paths use the shared discovery fact. Actual omitted relationships remain partial. The Ghidra call-coverage cache profile is now observed-call-inventory-and-discovery-v7, invalidating older semantics. CLI/MCP consumers retain those facts; no global computed-call scan or new target execution is introduced.

Validation and limits

379 provider/consumer tests, check:fast and docs:check passed. A real Ghidra 12.1.4 headless probe exercised production bridge code on a controlled x86-64 fixture without executing target bytes. The baseline failed the new inventory assertion. Real IDA was unavailable; IDA coverage uses adapter fixtures.

The workflow success matcher now matches the complete probe marker. Replaying the retained real-Ghidra output fails the former matcher and passes the corrected matcher; the literal matches the producer source. Diff checks passed. No additional real-provider run was performed for this one-line CI correction.

Existing read-only interpretation repair; no new provider, execution, injection, mutation, installer, or protection-recovery authority. Computed jumps/tail calls and per-edge call-site typing remain outside this change.

Author readiness

Human owner: @kaoru0822-kitauji

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

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. (Open: whether to include IDA, plus the reverse-direction and import-slot questions under Change and scope.)
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output. (Derived output only; no real-provider capture.)
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code

kaoru0822-kitauji and others added 2 commits October 31, 2026 15:57
…erage

Ghidra reported complete callee coverage when a computed call had one
ReferenceManager target, so trace_call_path, build_call_path and the
function comparisons turned the static candidate into a definite negative.
The bridge now keeps those targets as observed callees and marks callee
coverage partial, naming the computed call sites. IDA callee reads cannot
classify their call sites, so their callee coverage is partial too. The
Ghidra call-coverage profile revision refuses older snapshots.

A source-owned x86-64 bridge probe in the ghidra-bridge-sources job checks
the slot, register and direct-call controls against real Ghidra.

Fixes #8277

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added bug Something isn't working track:bugs Small-bug loop track PRs labels Oct 31, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T12:54:20.015629Z 8c0048f 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.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no actionable defect was found.

Summary

The PR keeps recorded computed-call targets while marking their callee coverage partial. IDA callee reads also become partial when call sites cannot be classified.

  • Ghidra keeps recorded computed-call targets but marks their coverage partial.
  • IDA callee reads mark edges partial when their call sites are unknown.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  G[Ghidra decoded computed call with recorded targets] --> P[Partial callee coverage]
  I[IDA callee read without call-site classification] --> P
  P --> E[Keep observed edges]
  E --> T[Shared forward traversal]
  T --> F{Goal found?}
  F -->|Yes| R[Reached]
  F -->|No| U[Unknown with remaining limits]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@morluto

morluto commented Nov 1, 2026

Copy link
Copy Markdown
Owner

A real shipped-library control for the import-slot tradeoff, using exact PR head b7e0b28083d3885ee80d3e23fee66c6ba03ef2dd and main 6e9ee97a69cb16c7150d8b550e705cba055ee4f0, Ghidra 12.1.4/JDK 21, macOS arm64, Node 24 and MCP SDK 2.3.1 (fetched compact schemas). The target was Homebrew Brotli 1.2.0 libbrotlidec.1.2.0.dylib, SHA-256 d7ac1e69b6c443341fb4302de0169d187489d58d8a641c8eadd6db9ca2cd0cbf.

  • Of the 14 exported BrotliDecoder* functions queried with procedure_callees, one changed from complete to partial: _BrotliDecoderDecompress. Three were already partial and the remaining ten stayed complete. This is one library, not a prevalence estimate.
  • otool shows that its 0x14dc blr x16 loads the pointer from 0xc000; dyld_info -fixups describes that location as an import binding for libSystem/___chkstk_darwin. Both REA revisions' resolve_native_call_targets retain Ghidra's same static computed-call reference, and the observed callee lists are identical. The import binding is evidence of the declared loader binding, not proof of immutable runtime contents or a reason to blanket-exempt imported slots.
  • A direct path from _BrotliDecoderDecompress to _BrotliDecoderDecompressStream remained reached; on the PR it also carried the computed-site residual and truncated: true. A path to _BrotliDecoderVersion was unknown on both revisions because other traversed callees were already partial; the PR added the entry's computed-site residual.
  • Comparing the same retained _BrotliDecoderDecompress dossier to itself changed from overall/calls unchanged on main to unknown on the PR, with 5 observed calls on both sides and the 0x14dc coverage limitation. This demonstrates the user-facing conservatism, not that the PR should assert target-set completeness.

Both sessions closed successfully, the target hash was unchanged, and no target code was executed. This extends the earlier source-built PE import control; it does not settle the loader-binding exemption, reverse coverage, runtime behavior, other hosts or other providers.

@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @kaoru0822-kitauji, thanks for the PR! This fix looks good to me. What's left: it has merge conflicts with main in src/ghidra/GhidraAnalysisProfile.ts and src/ghidra/GhidraRawProfileDigest.test.ts (merging main into the branch is fine). Happy to get this in once that's sorted out.

@morluto

morluto commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Call relationship coverage now separates observed inventory completeness from discovery limits. Ghidra callers retain recorded references while additional computed callers remain explicitly unknown; Ghidra and both IDA callee paths share explicit discovery limitations. Genuine omitted relationships still report partial coverage. The Ghidra cache profile was revised to invalidate older semantics.

Validation: 379 provider/consumer tests, check:fast and docs:check passed. A real Ghidra 12.1.4 headless probe exercised production bridge code on a controlled x86-64 fixture; no target execution. Real IDA was not available; IDA validation uses adapter fixtures.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c0048f7cf

ℹ️ 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".

@morluto
morluto merged commit 1f9bf8a into main Nov 9, 2026
7 of 9 checks passed
@morluto
morluto deleted the fix/8277-call-path-computed-target-uncertainty branch November 9, 2026 13:03
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 9, 2026
The xtensa merge brings main's morluto#8340, whose call_relationship_coverage
revision changes every Ghidra profile. Integration's pins also carry
Change 2's no_return_repair revision, so the values are new to both sides.
With morluto#8340's revision reverted in place, the previous pins hold (171 of 171).
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 9, 2026
The xtensa merge brings main's morluto#8340, which bumps call_relationship_coverage.
D1's snapshot from before base_address recorded v5, so its replay test now
asserts the recorded and current values as a pair, like the other upstream
revisions it sets aside. D1's own branch lacks morluto#8340 and needs the same
change when it next merges main.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 9, 2026
…o#8340

main's morluto#8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. With the revision reverted in place, the old
pins hold (79 of 79).
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 9, 2026
main's morluto#8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. Repin the raw digests this branch owns, and set
the revision aside in the replay test of the snapshot saved before
base_address, like the other upstream revisions it lists. With the revision
reverted in place, the old pins hold; only main's own two pins, which assert
v7, then fail.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 9, 2026
The D1 merge brings main's profile revisions since 71f680d, including
morluto#8340's call-coverage revision. These digests are the profiles main itself
computes for ARM ELF images outside the lane. With the merge's
GhidraAnalysisProfile.ts change reversed in place, the old pins hold (57 of
57).
@morluto morluto added the area: providers Provider and capability discovery, including provider proposal triage label Nov 23, 2026
morluto added a commit that referenced this pull request Nov 24, 2026
…ce (#8464)

* fix(ghidra)!: load ESP-IDF flash code in Ghidra's default address space

ESP-IDF's linker script reserves the addresses of .flash.text with the
NOBITS section .flash_rodata_dummy. Ghidra 12.1.4's ELF loader gives the
default address space to the later section, so .flash.text lands in an
overlay that its DWARF import, call-frame processing and default-space
references do not reach. Flash functions lose their DWARF signatures,
locals and no-return flags, each gets a one-byte shadow function in the
reservation, and pseudocode runs past calls such as esp_restart().

The ELF reader now records allocated ranges that an executable section
shares with another section, through one section-table visitor that the
RISC-V ISA reader also uses. When a NOBITS section starts with one
executable section and covers it, the RISC-V lanes commit both sections
to the analysis profile. ReaGhidraPrepareElfLoad.java then gives the code
the default address space before auto-analysis and keeps the reservation
as an uninitialized overlay; bytes, file offsets, symbols, functions and
entry points are kept. The session reports the outcome, and any memory
map that differs from the committed plan is refused. Images without such
an overlap keep their analysis profiles byte for byte.

BREAKING CHANGE: RISC-V images with this layout, such as ESP-IDF
ESP32-C6, H2 and H21 builds, report flash code at its ELF address
(0x42...) instead of .flash.text:0x42..., and their analysis profiles
change. RISC-V images with any other section overlap that involves
executable code are now refused with the overlapping sections named.
These include ESP-IDF v5.5.2 ESP32-C5 and C61 builds, whose second
reservation, .ext_ram.dummy, also covers .flash.text. See
docs/ghidra-riscv.md.

* fix(ghidra): bound the overlap sweep and check the load preparation

Domain:
- Find section overlaps with one sort and sweep that stops at the second
  overlap involving executable code, and read the ISA and the overlap in
  one section-table pass.
- Record the two sections that cause a refusal as witnesses. The Ghidra
  lane owns the refusal text and names them with their ranges.

Ghidra lane:
- Check the preparation report before the first lazily started analysis
  call, as for the calling-convention report.
- The pre-analysis script removes the code's overlay entry points, checks
  that no symbol or reference remains in the old overlay range, and reports
  the counts of the result. Its report echoes the blocks it left, which the
  client compares with the committed sections. A failed move refuses and
  rethrows. Reservation labels mark no entry points.
- Session limitations no longer state a planned move after a canonical
  outcome.

Verification:
- The ESP fixture defines ESP-IDF's absolute text bounds and the
  reservation's label. The lane checks their addresses, the entry points,
  file-offset uniqueness and snapshot replay, a reservation-first build,
  a pre-analysis refusal through analyzeHeadless and a truncated
  double-float section table.
- Boundary tests cover the refusal witnesses, a 10,000-section table and
  an ELF64 table.

* fix(ghidra): retarget references into the moved ESP-IDF flash code

The move takes the references from the code's range but not the
references into it. Besides the entry points, Ghidra 12.1.4's loader
records one data reference from the .flash.text section header to the
code, which the new post-condition refused in the RISC-V lane. Retarget
plain memory references and entry points into the old range to the moved
code; any other kind stays behind and is refused.

Removing the reservation block keeps the references into its range, so
the pinned symbols' entry points need no re-add.

* fix(ghidra): move labels past the ESP-IDF flash code's end with it

Ghidra 12.1.4 places a section-relative symbol at the section's end, such
as ESP-IDF's _etext, in the code's overlay space one byte past the block.
The move covers the block only, so the label stayed in the overlay and
ended up in the reservation. Everything in the code's overlay space now
follows the code: references are retargeted, labels outside the block are
created again in the default space, and the post-condition checks the
whole space. The script refuses when another block shares that space.

The ESP fixture defines _etext, and the lane checks its address.

* fix(ghidra): check prepared blocks by coordinates and address spaces

The client compared the pre-script's echoed block names with the ELF
section names, although section names are display only: an unnamed
section's empty name never matches the name Ghidra gives its block, so
that preparation was refused. It also accepted any reported address
spaces. The check now compares addresses, sizes and the code's file
offset, and requires moved code to go from an overlay into the
program's default space while its reservation leaves it, and canonical
code to stay there. An unnamed section is labelled by its index.

The docs and the pre-script now state that a failure during the move
may be refused without its reason, and that an entry mark on a
reservation label stays at its default-space address. The docs give
the llvm-objcopy route for the refused C5 and C61 builds. The lane
checks that no other block maps any of the code's file bytes, and the
overlap tests add the C5 and C61 section shape.

* fix(ghidra): bound the sections the overlap check keeps

The overlap check kept one record per allocated, non-empty section, and
only the file size limited their number. NOBITS headers take no file
bytes, so a crafted 1 GB ELF32 table holds about 27 million of them.
The check now keeps at most 65,280 (SHN_LORESERVE, from which ELF
counts sections through section zero) and reports the overlap as
unavailable beyond that, which the RISC-V lanes refuse as they refuse
a table that cannot be read.

* fix(ghidra): check RISC-V handshake reports before any analysis call

A RISC-V session that committed neither a calling-convention policy nor
a load preparation started its bridge lazily on the first query other
than `health`. An `elf_load_preparation` or calling-convention report
that the profile did not commit was then never checked, and the query
returned its result. Every RISC-V session now starts through the
checked handshake, so such a report closes the session before any
analysis call, whatever the first query is. A double-float session that
reports a preparation, and one that reports a calling-convention
policy, are now tested with `list_procedures`; both fail without the
fix.

Admission, profile parameters and profile digests do not change. If
Ghidra exits during the first query of a double-float session, the
error now tells the caller to reopen the session, as other checked
sessions do.

* fix(ghidra): skip analysis after a refused ELF load preparation

A refused memory map only wrote the refusal, so headless Ghidra still
ran seeds, auto-analysis and post-script analysis on a program that REA
then discarded. The preparation now turns off headless auto-analysis when
it refuses; later pre-scripts and the bridge still run, so the session
reports the reason.

The swap also renamed the reservation's overlay space to the section's
raw name, so a reservation named like another address space, such as
the RISC-V default space ram, or containing characters Ghidra rejects,
failed after the move. The space now takes the name Ghidra's memory map
derives for an overlay block: ':' and whitespace become '_', and a name
in use gains .1, .2 and so on.

verify:ghidra:riscv drops -noanalysis from the refusal run and checks
that Ghidra analyzed nothing, and a seventh fixture names the
reservation ram and checks that it moves into the overlay space ram.1.

* test(ghidra): read the load preparation report before Ghidra's log suffix

* test(ghidra): pin unchanged RISC-V profiles at main's revisions

main's byte-search (#8840), data-type (#8602) and reference revisions change every
Ghidra profile. With those revisions reversed, the old pins hold.

* fix(ghidra): name the moved RISC-V guide in load-layout diagnostics

The overlap refusal, the load-layout limitation and the bridge comments
named docs/ghidra-riscv.md, which main moved to docs/providers/.

* test(ghidra): check load-preparation facts instead of sentences

The refusal, report-check and handshake tests compared whole messages.
They now check the sections, coordinates, spaces and counts each message
must state, and the handshake compares the session's limitations with
ghidraRiscvLoadPreparationLimitations. Rewording the messages passes;
dropping a count fails.

* fix(ghidra): give the ESP-IDF load preparation unused temporary names

The preparation created its temporary blocks as <name>.rea, so a disjoint
section already named that refused an otherwise admitted image. It now
takes the first unused <name>.rea[.N]. verify:ghidra:riscv gains an
esp-edge-names fixture with such a section.

* fix(ghidra): keep both final block names free during the ESP-IDF swap

The code's temporary block could take the removed reservation's name,
such as a reservation named <code>.rea, and the reservation's rename
back then collided. The picker now skips both final names.
verify:ghidra:riscv's esp-edge-names fixture names its reservation
.flash.text.rea beside a disjoint .flash.text.rea.1.

* test(ghidra): repin the overlap-free RISC-V digests for main's #8340

main's #8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. With the revision reverted in place, the old
pins hold (79 of 79).

* test(ghidra): repin unchanged RISC-V digests for main's value-flow budgets

main's #9706 adds native_value_flow_projection to the shared analysis
semantics, which changes the profiles of images without a section overlap.
With that one revision removed, the previous pins hold (79 of 79).

* fix(ghidra): inspect RISC-V PIE section overlaps and refuse an unverified PIE reservation

Main admits RISC-V PIE, but this lane requires a section-overlap read
that the resolver made only for ET_EXEC, so every PIE was refused. A PIE's
section addresses are fixed offsets from its load base, so overlaps do not
depend on the base: read them for ET_DYN too. The NOBITS reservation
preparation is verified for ET_EXEC only, so a PIE that needs it is
refused. Main's producer identity now digests the bridge sources, so the
test that compared profile digests with main's is replaced by checking
that images without an overlap commit no load preparation.

* fix(ghidra): find an ESP-IDF reservation that Ghidra 12.2 marks executable

Ghidra 12.2 gives each section block the permissions of the first PT_LOAD
that contains its address, so a NOBITS reservation that shares the code's
addresses comes out executable and the preparation refused every ESP-IDF
image. Tell the reservation from the code by its missing bytes alone; the
displaced reservation is still made non-executable. The PIE refusal test
now uses the ELF64 lane, which admits PIE.

* fix(verify): read the ESP-IDF fixtures' identity where main's #11416 moved it

Evidence subjects and snapshot targets now carry their digest under
identity, as the rest of the RISC-V verifier reads it.

* docs(ghidra): describe the ESP-IDF load layout as verified on Ghidra 12.2

The real RISC-V lane now passes on Ghidra 12.2, whose ELF loader still puts
the code in an overlay when its reservation follows it. Name 12.2 where the
lane exercised that behaviour, and note that 12.2 can mark the reservation
executable. Measurements of Ghidra APIs the lane did not re-check keep
their 12.1.4 attribution.

* docs(domain): align RISC-V section-overlap JSDoc with ET_DYN inspection

---------

Co-authored-by: morluto <[email protected]>
morluto added a commit that referenced this pull request Nov 24, 2026
* test(raw): pin raw-binary admission and identity

Record what raw-binary loads produce today, so a later change to how the
load is represented has to keep it:

- every admission result and pairing message over a grid of
  architectures, entry spellings and file sizes;
- the analysis profile digest for each raw family;
- the snapshot target and query identity of a raw ARM load;
- the complete raw-binary load image for the ARM fixture.

The values were computed at d6f88be without changing production code.

* refactor(raw): carry the raw load selection as one admitted value

The caller's raw load selection (format, architecture and entry_point)
travelled as three loose optional fields through about ten layers:
CLI flags, MCP open, direct analysis (five call sites), the session
port and open options, and target resolution. Every new load input had
to be threaded through each of them. The CLI and MCP boundaries now
build one NativeLoadSelection, and target admission is its only reader.

Admission now returns one RawBinaryLoad, carried on the raw target as
rawLoad. It names the base address of file offset 0 and the entry
separately. Before, the provider client, the load-image attestation,
the analysis profile and the snapshot target each read the entry and
assumed it was also the base. Admission still sets the base to the
entry, so nothing a caller sees changes.

No contract or behaviour change. The tests pinned in the previous
commit pass unchanged: the admission and pairing result grids, the
per-family profile digests, the raw snapshot target and query id, and
the complete raw load image. Tests that build raw targets use the new
rawLoadAtEntry fixture.

* feat(raw): state the M-profile raw load contract

Record provisional decision D1 (#4246) as code before implementing it,
so maintainers can confirm or redirect the contract cheaply.

- src/domain/rawArchitectureVariant.ts owns the variant vocabulary:
  armv6-m, armv7-m, armv7e-m, armv8-m.base and armv8-m.main, each an ARM
  M profile with Thumb-only code and an M-profile vector table. It also
  owns the closed sets that persisted entries use: isa_mode, role (the
  entry's function: entry or reset) and basis (how REA chose it: caller
  or vector-table).
- GHIDRA_RAW_VARIANT_LANGUAGES maps them to ARM:LE:32:Cortex and, for
  v8-M, ARM:LE:32:v8-m, which has the v8-M encodings Cortex lacks. This
  follows the GNU architecture names in Ghidra 12.1.4's ARM.ldefs.
  Provider language ids stay out of the domain.
- CLI and MCP gain architecture_variant, and with it base_address and
  vector_table_address; the open_binary description explains them.
  Narrow first: a separate base is accepted only with a variant, the one
  lane verified with it. The pairing check names the input to correct,
  so MCP error paths come from one owner, and
  rawBinaryVariantSelectionIssue owns the rules for the new inputs.
  Legacy pairing messages and paths are unchanged and pinned.
- Raw target summaries gain optional base_address, architecture_variant
  and vector_table_address. The load-image union gains the versioned
  segments shape (version 1): one file-backed segment, entries with
  address, isa_mode, role and basis, and, when the basis is the vector
  table, the table address with the two words read from it.
- docs/raw-binary.md describes the inputs and Evidence, and two levels
  of identity: coordinates from resolved values only, sessions and
  snapshots also from the provenance that results report. It keeps the
  decision record, which includes not applying Ghidra's
  processor-defined labels to variant loads.
- Tests are generated from the tables: pairing per variant and family,
  the Ghidra binding per variant, and the docs table and the skill
  reference's variant names against the tables. The persisted variant
  names are pinned.

Admission refuses the new inputs until the following commits implement
them. The base_address input follows #4927 by Jean Granié.

* feat(raw): admit M-profile loads at a separate base

Raw admission now implements the D1 inputs:

- architecture_variant must match the family. Its code runs in Thumb
  state, so an even entry is accepted where generic ARM needs 4-byte
  alignment. An odd entry is refused as a Thumb interworking address.
  The error diagnostics give the even code_address and suggest omitting
  entry_point, so the caller's value is never silently changed. An odd
  generic ARM entry keeps its earlier reason and gains a hint to use
  the M-profile inputs.
- With a variant, base_address maps file offset 0. The entry must lie
  inside the mapped image, and the address width is measured from the
  base.
- With a variant and a base but no entry_point, admission asks the
  resolver to read the first two words of the vector table. It reads
  them at vector_table_address, or at the base when that is omitted.
  Word 1 must be odd and point inside the image; the entry is that word
  with bit 0 cleared. Word 0, the initial stack pointer, is recorded as
  observed and not validated.

Admission applies the same rawBinaryVariantSelectionIssue rules as the
pairing check, so CLI and MCP refuse the same selections in the same
words.

RawBinaryLoad records the variant, the entry's instruction set, and
whether the entry was the caller's or read from a vector table. It keeps
canonical values only: caller spellings are not facts about the load,
and a session reused across spellings must report the same load. The
grid pin is recomputed at d6f88be without the spelling and is
otherwise unchanged. isLegacyRawLoad decides legacy equivalence on
resolved values. Target summaries report base_address,
architecture_variant and vector_table_address only for loads that are
not legacy-equivalent. The load_selection_rejected recovery now lists
the new inputs.

* feat(raw): give M-profile loads a versioned identity

rawLoadIdentity is the one identity function for raw loads. A
legacy-equivalent load has no new identity, so its analysis profile,
coordinate context, snapshot target and query ids stay exactly as
before; the pinned digests prove it.

Any other load gets raw_load (version 1), built from canonical resolved
values: the base, the variant, the vector table that Reset was read
from, and the entry's address, instruction set, role and basis. The
role names the entry's function (entry or reset); the basis records how
REA chose it (caller or vector-table). Every load fact that summaries
and Evidence report is in it, provenance included, so a reused session
never reports what the current request did not choose. Spellings are
excluded, so another base spelling, or an explicit vector table at the
default location, reuses the same session. Absent values are omitted,
as in the summaries and Evidence.

- The snapshot target gains optional raw_load, compared canonically.
  Older snapshots have none and keep matching legacy loads.
- The Ghidra profile commits raw_load, base_address, the variant's
  language, the Thumb entry context, processor_labels not-applied-v1
  and load_image_evidence independent-raw-segments-v1.
- The function coordinate context covers resolved values only. Beside
  the language and entry it already covers, it gains base_address and
  the entry's decode context. Analyses that differ only in role, basis,
  vector table or a variant with the same decoder stay comparable: a
  caller-named entry and Reset at one address share a coordinate
  context while their sessions stay separate.
- The persisted variant names are pinned in raw_load.

* feat(ghidra): open M-profile loads at their base in Thumb state

The Ghidra raw lane now reads the committed load instead of assuming
that the base is the entry:

- The decoder comes from the variant (ARM:LE:32:Cortex or v8-m);
  generic ARM keeps ARM:LE:32:v7.
- BinaryLoader maps the file at the base. A variant load is imported
  with -loader-applyLabels false: ARMCortex.pspec names the vector table
  at ram:0x0-0x40 and marks every handler slot an entry, reserved slots
  included, which at base 0 would cover the image and the code after
  the table. Loads without a variant keep the language default.
- ReaGhidraPrepareRaw receives the base, the entry and the committed
  entry context. It requires the entry inside the file-backed block
  and, for Thumb, TMode=1 at the entry, and fails closed otherwise.
- The bridge descriptor carries entry_context_register. The bridge
  accepts only the registers GHIDRA_RAW_ENTRY_CONTEXT can commit, and a
  launcher test keeps the two equal. It reports that register in
  load-image observations, so it no longer needs to match a language
  string to know about TMode.
- Load-image attestation keeps the raw-binary image unchanged for
  legacy-equivalent loads; the pinned digest proves it. Other loads get
  the segments image (version 1): one file-backed segment at the base,
  the entry with its isa_mode, role and basis, the vector table address
  and both words read from it when Reset was derived, an
  entry_context.TMode check, and a check that the committed entry is
  the only external entry. Spellings of the same load give the same
  image, so a reused session reports what the current request would.
- Raw limitations are derived from the load. Legacy wording is kept,
  except the claim that Cortex-M is unsupported.

The base and entry separation in the prepare script, the TMode check
and the entry-context attestation follow #4927.

Co-authored-by: jgranie <[email protected]>

* test(raw): check saved raw snapshots and schemas stay compatible

The segments load image is the first persisted shape these inputs add,
so this commit adds the historical-snapshot and schema checks with it:

- A raw-binary snapshot written at d6f88be, before base_address,
  still parses. It matches the same load admitted today, and its
  load-image Evidence replays and equals what this version produces. An
  M-profile load of the same file does not match it.
- The earlier raw-binary Evidence schema rejects a segments image, so
  readers that predate it refuse the new shape instead of misreading
  it. An unknown segments version is rejected as well.
- The advertised inspect_native_load_image output accepts both the
  saved and the segments images. The advertised open_binary input
  accepts calls from before base_address beside the new inputs, and
  rejects variants outside the table.

* test(ghidra): verify M-profile raw loads against real Ghidra

Add npm run verify:ghidra:cortex-m, adapted from the #4927 verifier and
its Cortex-M0 fixture. It drives the compiled CLI and stdio MCP server
with source-owned images:

- the Cortex-M0 (armv6-m) image at bases 0x0 and 0x08000000, and after
  a 256-byte boot2-style header opened with vector_table_address;
- a Thumb-2 image (movw, movt, ldr.w, it, cbz) opened as armv7-m at 0x0
  and as armv7e-m at 0x08000000;
- an armv8-m.base image with movw, movt, cbz and udiv;
- an armv8-m.main image that sets MSPLIM, which only the v8-M decoder
  names.

LLVM is the independent oracle. The lane assembles each fixture's
annotated source for its triple, requires identical bytes, and requires
Ghidra to decode the same mnemonics in Thumb state. Mnemonics are
compared without width qualifiers (ldr.w) or the dot Ghidra puts before
an IT condition (mov.eq). The Cortex-M0 fill after its last return is
declared as data, so neither decoder counts it as code. The lane also
checks that Reset, read from the vector table, is the only entry Ghidra
reports, the segments load image and its TMode check, decompilation,
odd-entry refusal with code_address while the session is kept, CLI/MCP
parity, unchanged legacy identity, refusal of a base without a variant,
snapshot reuse across base spellings and refusal across variants,
unchanged source bytes, and owned cleanup.

Only named settings reach REA, which fixes the #4927 review finding that
an exported REA_GHIDRA_LANGUAGE_ID broke the verifier.

Verified on Linux x86_64 (Debian 13) with Ghidra 12.1.4, OpenJDK
21.0.12 and LLVM 19.1.7; the oracle also runs with Apple LLVM 21. Not
run on macOS or Windows.

Co-authored-by: jgranie <[email protected]>

* feat(raw): add the armv8.1-m.main variant

ARMv8.1-M Mainline, as in the Cortex-M55 and Cortex-M85, gets its own
architecture_variant row, decoded with ARM:LE:32:v8-m. Ghidra 12.1.4's
ARM.ldefs lists armv8.1-m.main as a GNU name of that language, and its
slaspec builds it with VERSION_8M. The next commit's real-Ghidra case
checks that it decodes ARMv8.1-M low-overhead loops and MVE.

Folding v8.1-M into armv8-m.main would use the same decoder but drop the
profile from identity, and splitting it out later would change identity
again. The decision record now says so.

The docs table, the skill reference and the pinned persisted names
follow the table. The refused-spelling test now uses armv8.1m.main, the
LLVM triple's spelling, since armv8.1-m.main is accepted.

* fix(ghidra): report Ghidra's ARMv8.1-M loop flow for armv8.1-m.main

On real Ghidra 12.1.4, the ARM:LE:32:v8-m decoder names the ARMv8.1-M
low-overhead-loop branches correctly but gets their flow wrong. In the
Cortex-M55 image the next commit verifies:

- WLS at 0x46 branched to 0x5a, 2 bytes short of its target 0x5c and
  inside the LE instruction;
- LE at 0x58 branched unconditionally to 0x4e, 4 bytes past the loop
  start 0x4a, with no fall-through.

So the code after the loop was never disassembled, and a function with
such a loop is cut short. Results of armv8.1-m.main sessions now carry
that limitation, and the raw-binary docs state it, instead of the claim
that the decoder handles the low-overhead loops. MVE loads, stores and
VCTP decode as LLVM decodes them.

* test(ghidra): verify an ARMv8.1-M image against real Ghidra

The cortex-m lane gains a Cortex-M55 image opened as armv8.1-m.main at
base 0x0: a WLS/LE low-overhead loop around the MVE instructions VLDRW,
VCTP and VSTRW. LLVM assembles it for thumbv8.1m.main with
-mcpu=cortex-m55 -mfloat-abi=hard, because clang 19 refuses MVE under
the default soft-float ABI. The oracle takes the CPU and float ABI from
the fixture.

Ghidra must decode each instruction it reaches with LLVM's mnemonic in
Thumb state, as in the other cases. A data type that gives only the
element size (Ghidra vldrw.32) matches one with signedness (LLVM
vldrw.u32); opposite signedness still fails. The lane now reports every
disagreement in one run instead of stopping at the first.

Ghidra 12.1.4 does not follow the loop's exits (see the previous
commit), so this case requires the pop after the loop to stay
undisassembled, records both loop branches' flow, and checks that the
results report the limitation. Base 0 also checks that the v8-m
decoder's vector table gets no processor labels.

Verified on Linux x86_64 (Debian 13) with Ghidra 12.1.4, OpenJDK
21.0.12 and LLVM 19.1.7: all eight cases pass. The oracle also runs with
Apple LLVM 21. Not run on macOS or Windows.

* refactor: name the variant vocabulary after architecture_variant

The variant table is no longer only for raw loads: the M-profile ELF
lane uses the same vocabulary. Its internal names now follow the public
input, architecture_variant, without an ARM M-profile prefix that would
need renaming again once other architectures get variants:

- src/domain/rawArchitectureVariant.ts becomes architectureVariant.ts,
  together with its test and the docs conformance test;
- RawArchitectureVariant, RAW_ARCHITECTURE_VARIANTS,
  RAW_ARCHITECTURE_VARIANT_NAMES, rawArchitectureVariantSchema and
  rawArchitectureVariantRow drop the raw prefix;
- GHIDRA_RAW_VARIANT_LANGUAGES becomes GHIDRA_VARIANT_LANGUAGES, and
  ghidraRawProcessorLabels becomes ghidraVariantProcessorLabels.

Identifiers only. Saved values, schemas, lane ids and the
processor_labels value are unchanged: the recorded catalog digests and
MCP catalog are byte-identical before and after, the pinned profile and
snapshot digests pass unchanged, and no snapshot fixture changes.

Names that mean the raw load keep theirs: RawBinaryLoad, rawLoad,
raw_load, and the vocabularies of its entries (RAW_ENTRY_ISA_MODES,
RawEntryIsaMode, RAW_ENTRY_ROLES and RAW_ENTRY_BASES).

* refactor(ghidra): keep variant decoder limitations beside the languages

The low-overhead-loop limitation lived in the raw-binary limitations, but
it describes Ghidra's ARM:LE:32:v8-m decoder for armv8.1-m.main whatever
container holds the code. The M-profile ELF lane maps ELF builds to the
same variants and must report the same text.

GHIDRA_VARIANT_LIMITATIONS now sits beside GHIDRA_VARIANT_LANGUAGES and
states the limitations of every variant, so adding a variant also
decides them. Raw results read it; their text and order are unchanged.

* fix(raw): require base_address with every architecture_variant

A variant without base_address mapped the image at its entry, and the
odd-entry suggestion led callers there: retrying with the even
code_address and no base mapped the vector table at Reset, and the
segments image still verified.

architecture_variant now requires base_address, the address of file
offset 0, and the odd-entry suggestion no longer offers a retry without
a base. A code fragment that starts at its entry passes that address as
its base. Loads without a variant are unchanged.

* fix(raw): align vector tables as VTOR does and refuse Reset inside them

VTOR.TBLOFF holds address bits 31:7 wherever VTOR exists (ARMv6-M with
VTOR, ARMv7-M, ARMv8-M), so a vector table is at least 128-byte
aligned. Admission accepted any 4-byte-aligned table, so naming the
Reset slot (0x10000104) instead of the table (0x10000100) read NMI as
Reset and reported it with role reset. A named table and the default at
the base now need 128-byte alignment.

A Reset word that points into the 8 table bytes just read is refused
too. Even, outside and inside Reset words stay load_selection_rejected,
with the observed words as diagnostics: a raw dump has no format they
can violate, and the usual cause is a wrong base, table or variant.

* fix(ghidra): key variant coordinates by base, not entry

A variant load maps file offset 0 at base_address, so with the decoder
and the entry's decode context the base fixes every coordinate. The
coordinate context still held the entry address, so functions found
from two entries of one image did not compare.

Variant coordinate contexts now take the base from the admitted load
and leave the entry out. Variant profiles commit raw_load without flat
entry_point and base_address copies of it; entry_context stays as
Ghidra's seeding commitment, which raw_load does not record. Legacy
profiles keep their parameters and digests.

* refactor(raw): discriminate the segments load image by layout

The segments load image named its shape with variant: "segments", beside
architecture_variant, which names the decoder. It is now
layout: "segments", as layout names data shapes elsewhere in REA. The
shape is unreleased, so no saved Evidence uses the old key.

* docs(raw): record why vector-table words keep their full width

vector_table.initial_stack_pointer and reset_vector are words read from
the table, not addresses: REA reports format words such as GPU
code-object flags and metadata tokens as full-width hex, and the entry
already holds Reset's canonical code address. The schema, admission and
raw-binary guide now say so.

* docs(raw): record why the seeded entry function is named entry

Ghidra names the function REA seeds at a raw entry entry, whatever the
entry's role, as its loaders name a program entry. The load image
reports the role; naming the function after it, as CMSIS Reset_Handler,
would claim a symbol the image does not carry. The prepare script and
the decision record now say so.

* fix(raw): name the refused load input in error details

Raw admission refused a pairing with the rule's message but dropped the
field it named, so callers had to read the input to correct from prose.
Each raw admission refusal now names the input to blame, and
BinaryTargetError projects it as details.field on the CLI and MCP; the
Reset-word refusals and a file too short for a table at its base name
none. Pairing refusals from the target resolver keep their field too.

MCP refuses invalid pairings in the open_binary input schema before
admission; that error reports path [] as it does on main and is left
unchanged here.

* docs(raw): state that results keep no caller spellings yet

The raw_load identity comment claimed Evidence parameters keep the
caller's spellings of the load inputs. They do not: summaries, Evidence
and snapshots report canonical addresses only, as legacy entry_point did
before these inputs. The comment and the raw-binary guide now say so,
and the decision record names the gap and the caller_input_path pattern
that could close it additively.

* docs(raw): explain why reused sessions cannot report stale vector words

raw_load leaves the two vector-table words out, yet results report
them. They cannot go stale: sessions and snapshots also match the file
digest, and with the base and the table address it fixes the bytes the
words are read from. The identity comment and the raw-binary guide now
say so.

* docs(raw): scope architecture_variant to the ARM M profiles

The generic raw-language limitation listed 68020, ColdFire and other
"processor variants" as unsupported, which read as future
architecture_variant values. It now says those languages are not
offered and that architecture_variant names only ARM M profiles.

The variant table and the decision record also state the scope: the
base requirement, Reset derivation and label policy hold for every row
because every row is an M profile, and a variant of another family
would first make them per-row properties.

* docs(raw): state each load pairing rule once in open_binary

open_binary said that architecture_variant requires base_address, and
that entry_point may then be omitted, in its tool description and again
in three field descriptions; the default compact input profile
advertises all of them. Each rule now sits on the field it constrains,
and the tool description points to the M-profile lane in one sentence.
CLI flag help follows the same split.

Measured from tools/list of a server built from this source, the trim
saves 237 bytes of open_binary in each input-schema profile.

* refactor(ghidra): let session limitations own the variant load facts

A segments load image restated that only the file is mapped, that
processor labels are not applied and where Reset came from, beside the
session limitations that every result, the load image included, already
carries. The load image now states only what its verification covers
and requires; the session limitations are the one owner of the load
facts.

* refactor(ghidra): launch with the label policy the profile committed

The Ghidra client recomputed the processor-label policy from the
target's variant instead of reading the processor_labels value the
analysis profile commits, so the launch and the profile each held their
own copy of the rule. The client now reads the committed value, named
once as GHIDRA_PROCESSOR_LABELS_NOT_APPLIED, and a behavior test checks
that a variant profile reaches the launcher without labels.

* refactor(raw): let the vector-table read carry its length

Admission and the target resolver each knew that the vector table read
is 8 bytes: the resolver passed a literal 8 and admission checked one.
RawBinaryVectorTableRead now carries byteLength beside fileOffset, and
admission derives its bounds, inside-table check and message from one
constant.

* test(raw): compare saved raw images by their facts, not their prose

The compatibility test required a snapshot saved before base_address to
equal today's raw load image exactly, limitation text included, so any
rewording of a limitation would fail it although no fact changed. It
now compares every field except limitations.

* test(ghidra): expect not-in-listing where the Cortex-M lane stops

Since #7823, Ghidra reports an address in memory with no listed
instruction or data as not-in-listing instead of undecodable. The
Cortex-M55 case expects the pop after its low-overhead loop to stay
undisassembled, so the lane now expects not-in-listing there.

* test(raw): pin raw identity to main after its instruction-status revision

#7823 commits instruction_status in every Ghidra profile, so the legacy
raw digests pinned at d6f88be and the variant digest changed, and the
snapshot saved before base_address no longer replays on main either.
The legacy pins now hold main's own digests at 07dfd12, computed
without these inputs; the merged branch matches them for all six
families. The variant digest is re-pinned.

The compatibility test now checks that the saved snapshot keeps its
target, that its profile differs from today's only by instruction_status,
and that its load-image facts equal today's. The raw-binary guide states
replay relative to REA without these inputs.

* test(ghidra): own the Cortex-M lane's LLVM and CLI commands

The lane's LLVM oracle ran clang and llvm-objdump through execFile with
no deadline, and its CLI parity launch used execFile directly, so a
hung tool could stall the lane and a killed one could leave children
behind. All three now run through createVerifierCommands, the owner
that stops each process tree, with a 120-second deadline for LLVM and
240 seconds for the CLI, as the ESP image verifier does.

The oracle writes under the lane's workspace instead of its own
temporary directory, and the lane closes the owner before removing that
workspace; a failed close keeps it for inspection.

* test(raw): derive the Reset fixtures from one Thumb image

The segments tests verified a Reset load admitted for 16 bytes, with
vector words supplied separately, against the 4-byte ARM fixture, so
the image they called verified held neither the table nor the entry at
0x8000008. fixtureRawBinaryLoadImage now takes the image bytes and the
load and derives the digest, size, mapping, entry and bound language
from them; its defaults keep the legacy fixture unchanged.

The Thumb tests and the compatibility test's segments image use the
Cortex-M0 image the real lane verifies, admit Reset from its own first
eight bytes, and name a caller entry at its add_three function. A
declaration file lets TypeScript tests import that fixture.

* docs(raw-binary): say that recording load spellings would not be additive

The Evidence envelope is strict, so a later field that keeps a load
selection's spellings would make records that REA versions without it
refuse, as caller_input_path did. The guide called that change additive.

* docs(raw-binary): tell callers how to keep their load spellings

Results report canonical addresses, and an omitted vector_table_address
reads as one at the base. A caller that needs its exact spelling keeps
its own request beside the Evidence, with the record's evidence_id: the
raw-binary guide says so for people, and the skill's raw-image paragraph
for agents, loaded only when an agent opens that reference.

* test(ghidra): keep raw digests at main's byte-search and data-type revisions

* test(domain): check raw-binary refusal facts, not sentences

The new variant and raw-binary refusal tests compared whole explanations.
They now check the rejected field, constraint and diagnostics exactly, and
match the parameter names and addresses each reason must state as whole
tokens through tests/support/statingFacts.ts. Rewording a refusal passes;
dropping its mapped range fails. The admission and pairing grids stay
digests of results computed on main before this change.

* docs(adr): move the M-profile raw load decision into an ADR

The raw binary guide held decision D1 inline. Record it under
docs/adr/firmware/ with Nygard sections and Proposed status, index it,
and link it from the guide.

* test(ghidra): repin digests and replay for main's call-coverage revision

main's #8340 bumps call_relationship_coverage from v5 to v7, which changes
every Ghidra profile digest. Repin the raw digests this branch owns, and set
the revision aside in the replay test of the snapshot saved before
base_address, like the other upstream revisions it lists. With the revision
reverted in place, the old pins hold; only main's own two pins, which assert
v7, then fail.

* chore(plugin): regenerate the skill bundle from the authored skill

* test(raw): keep the target route diagnostics within the function length limit

* docs(raw): record the M-profile lane on Ghidra 12.2

* refactor(raw): read vector words and own the Cortex-M workspace through their shared owners

Main's architecture guards require BinaryReader for numeric reads and VerifierFixture for verifier fixture roots.

* fix(raw): name raw-binary as the format of vector-table read failures

* fix(verify): remove the Cortex-M workspace after a verified run

closeEarly stops the command owner but keeps the root, so every successful
run left its fixtures, snapshots and LLVM outputs behind while reporting
cleanup complete. Release the workspace once process lineage is verified; a
failed run still keeps it for diagnosis.

* chore(verify): record open_binary's input schema with the M-profile load fields

CI's package build compares the committed advertised-schema summaries with
the packaged catalog; regenerated with
`node scripts/verify-advertised-schemas.mjs --update-summary`.

* test(cli): expect open_binary's M-profile load flags in the CLI command table

Main's command-table test (#11777) pins the flag of each open_binary field
a direct-analysis command takes; D1 adds --architecture-variant,
--base-address and --vector-table-address.

* test(cli): record the CLI help goldens with the M-profile load flags

Commands that open a target list open_binary's options; D1 adds
--architecture-variant, --base-address and --vector-table-address.
Recorded with REA_RECORD_CLI_PARITY=1 from the built CLI.

* docs(raw-binary): qualify snapshot replay under the producer rule

A load without the M-profile inputs keeps its analysis profile inputs,
snapshot target and load image, but every analysis profile also commits
to the REA release and packaged bridge scripts. A snapshot saved by an
earlier release is therefore refused after an upgrade either way. Say
so, and point to the Ghidra guide's producer rule.

* test(ghidra): report why Cortex-M verifier cleanup could not be checked

The verifier compared the completed lineage's status and descendants
directly, so an unavailable lineage failed as a bare equality without
its reason. Use the shared assertVerifierCleanupComplete, which names
the reason, as docs/development/testing.md requires.

* fix(domain): compare raw-load functions by coordinates, not entry provenance

compare_functions and build_call_path required equal target identity,
which for a non-legacy raw load includes the entry's address, role and
basis and the vector table it was read from. Two loads of the same image
at the same base, one with Reset read from the vector table and one with
a caller-named entry, therefore stopped comparing, although their
function coordinate contexts match and the raw-binary guide says they
compare.

targetIdentity now owns sameTargetCoordinates, which keeps a raw load's
base and variant and leaves out how it chose its entry; a legacy load
still places addresses by its entry. Both comparison workflows use it.
Session, snapshot and Evidence subject matching keep the full identity.

* fix(domain): align coordinateKey canonicalization and target diagnostics with main

---------

Co-authored-by: jgranie <[email protected]>
Co-authored-by: morluto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage bug Something isn't working track:bugs Small-bug loop track PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Resolved Ghidra indirect reference can yield a definite negative call path

2 participants