Skip to content

feat(ghidra): admit RISC-V ilp32 ELF with a derived calling convention - #8229

Merged
morluto merged 9 commits into
morluto:mainfrom
Entrpi:feat-ghidra-riscv-ilp32
Oct 31, 2026
Merged

morluto merged 9 commits into
morluto:mainfrom
Entrpi:feat-ghidra-riscv-ilp32

Conversation

@Entrpi

@Entrpi Entrpi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Decision D3 is made on #7477: option 1, a written policy per ABI, ilp32 first. Redirect it there or in this review if you disagree. Review from cc4e86e99, the first commit: it is the decision itself (types, the lane and policy tables, the session-report schema, docs with the durable record, and table-driven tests) and changes no behaviour. Later commits implement it. A redirect now costs what the record below says; after a release it needs a new policy id or lane id.

Part of the embedded firmware roadmap #7955.

Decision record: D3, RISC-V float ABIs (decided on #7477, 31 Oct 2026)

  • Choice.
    • Little-endian ELF32 ET_EXEC images that declare the soft-float ABI (e_flags float-ABI bits 0, ilp32) are admitted through a new lane, elf32-exec-le-soft-float-generic-v1. Lane ids are built from their fields, elf<class>-exec-le-<float ABI>-float-generic-v1, so feat(ghidra): admit RISC-V position-independent executables (#4487) #4811's load model becomes one more field.
    • The lane keeps the pinned RISCV:LE:32:default language with the gcc compiler specification. Every RV32 language in Ghidra 12.1.4, including the deprecated soft-float RV32I/RV32IC/RV32IMC variants in old/riscv_deprecated.ldefs, uses the same riscv.ilp32d.sla decoder; only the compiler specification differs. So REA corrects the calling convention, not the language.
    • The ilp32 policy (ilp32-prototype-v1), written per topic in docs/ghidra-riscv.md#ilp32:
      • integer, pointer and float arguments: a0–a7, then 4-byte stack slots;
      • double and other 8-byte scalars: a register pair, low word in the lower register, with no alignment for named arguments; with one register left, the low word in a7 and the high word on the stack;
      • aggregates up to 8 bytes: one or two integer registers as laid out in memory, also when every member is floating-point; larger ones by reference;
      • returns: as the first argument of the same type; larger values through a caller buffer whose address is an implicit first argument in a0;
      • values over 8 bytes, such as a 16-byte long double: by reference;
      • variadics: the integer convention, with 8-byte-aligned arguments in an aligned (even-numbered) register pair;
      • preserved registers: s0–s11 and sp; no floating-point register.
    • Applied in the bridge. After analysis, ReaGhidraRiscvCallingConvention.java derives __rea_ilp32 from the program's own default prototype. It removes every floating-point argument and return entry and every rule that assigns floating-point storage, and moves fs0–fs11 from the preserved list to the killed-by-call list. A rule before the input list's final join passes any value of 9 bytes or more by reference. One derivation serves every policy: a policy row sets the floating-point entries and preserved registers, and every row gets the by-reference rule, so ilp32f becomes one more row. The script installs the result as a specification extension and assigns it, with dynamic storage, to every non-thunk function, every external function and every function definition (the prototypes of indirect calls). Thunks follow their targets. The script fails, and writes no report, if the derived prototype or any function still uses a floating-point register, or if the prototype does not pass a 16-byte value by reference.
    • The profile commits riscv_calling_convention: ilp32-prototype-v1. The bridge reports {policy, functions, definitions} last, and REA requires that report exactly when the profile commits the policy, before serving any operation.
    • ISA declaration. The lane requires .riscv.attributes Tag_RISCV_arch with an RV32I base and only extensions that Ghidra 12.1.4's generic RV32 language implements with p-code: m, a, f, d, c, zicsr, zifencei, and the subset names zmmul, zaamo, zalrsc, zca, zcf, zcd. Anything else is refused and named. That covers Zcb, Zcmp and Zcmt (not decoded), Zb*, Zk* and P (draft encodings marked unimpl), and vendor extensions such as xesploop, xespv and xespdsp (custom-opcode placeholders only). A missing section or tag is refused because the extensions are unknown.
    • Profile shape. Soft-float profiles add riscv_elf.float_abi: "soft" and riscv_elf.arch beside the existing float_abi_double boolean. Double-float profiles keep their exact parameters, so their digests, sessions and snapshots do not change.
    • ilp32f keeps a written policy (docs/ghidra-riscv.md#ilp32f) and stays refused until it is implemented and verified; see "Not included". Quad-float, RVE, TSO and ELF64 soft- or single-float images stay refused.
  • Alternatives (and what switching to each would take):
    • Pin the deprecated soft-float languages (RISCV:LE:32:RV32IMC and others, riscv32.cspec): REA's catalog would have to read old/, the variants cover only I, IC and IMC, Ghidra marks them deprecated, and no stock specification models ilp32f.
    • Assign __rea_ilp32 only to callables whose types use floating-point values, as the MIPS soft-float lane does: typed storage is identical, but prototypes Ghidra infers for untyped code keep the ilp32d model, which can still claim fa0 in an ilp32 image that contains F or D instructions. Switching is one predicate in the script and a new policy id.
    • Admit with a limitation and no correction: a reduced-capability contract that needs its own review, because arguments, returns and aggregates become unverified.
    • Keep refusing: the lane row becomes a refusal again.
    • Admit images without Tag_RISCV_arch, or refuse a denylist of known extensions: a declaration REA cannot check would count as compatible. Widening the decoded set later is additive.
    • Add float_abi and arch to double-float profiles too: one shape for all lanes, but every existing RISC-V session and snapshot is invalidated.
    • Ship ilp32 and ilp32f together (the open question in [Design] Admit RISC-V ilp32 and ilp32f ELF in the Ghidra lane with a per-ABI calling-convention policy #7477): ilp32f needs a rule for a structure of one float and one integer that Ghidra's model lacks (measured below), so it ships separately with its own fixtures.
  • Semantic owner and consumers.
    • Owners:
      • src/domain/riscvIsaDeclaration.ts: the e_flags float-ABI vocabulary, the .riscv.attributes and Tag_RISCV_arch parsers, and the section scan.
      • src/ghidra/GhidraRiscvProfile.ts: GHIDRA_RISCV_LANES (admission and lane ids), GHIDRA_RISCV_CALLING_CONVENTIONS (policy ids, ABI and prototype) and GHIDRA_RISCV32_DECODED_EXTENSIONS.
      • bridge/ghidra/ReaGhidraRiscvCallingConvention.java: how a policy becomes a Ghidra prototype.
    • Consumers: target resolution, Ghidra admission, the analysis profile, the provider client and launcher, the session handshake, caller-project history, verify:ghidra:riscv and docs/ghidra-riscv.md (a test keeps the docs in step with the tables). Later work reuses the table: ilp32f adds a row; RISC-V ESP images (F6) pick a row through D5.
  • Costs of changing it.
    • Code: S. A lane or policy is one table row plus the Java derivation.
    • Compatibility: once released, the soft-float lane id, riscv_elf.float_abi, riscv_elf.arch and riscv_calling_convention are persisted in sessions, snapshots and Evidence. A changed derivation ships as a new policy id (ilp32-prototype-v2), which invalidates soft-float snapshots only.
    • Migration: none for admitted targets; double-float profiles are pinned by tests. Previously refused soft-float targets become admitted.
    • Verification: rerun npm run verify:ghidra:riscv (Ghidra 12.1.4, JDK 21, LLVM with RISC-V: clang, lld, readelf, objdump).

Summary

ESP32-C2, C3, C5, C6, C61, H2 and H21 builds are ELF32 ilp32 images, which REA refused at the RISC-V lane's double-float check. Ghidra's RV32 compiler specification models ilp32d: on Ghidra 12.1.4 its stock prototype decompiles this PR's fixture call rea_riscv_abi_pick(1.5f, 2.5f, sel) as rea_riscv_abi_pick(in_fa0,in_fa1,0x3fc00000). With this PR it decompiles as rea_riscv_abi_pick(1.5,2.5,sel), and every argument of the fixture's calls sits where the compiler put it.

rea function c3.elf rea_riscv_abi_caller --provider ghidra --json

now opens an ilp32 image in the soft-float lane if its Tag_RISCV_arch declares only decoded extensions, as ESP-IDF's base strings for these chips do; other extensions are refused by name.

Refs #7477, #2063. Coordinates with #4811 (RISC-V PIE), which edits the same admission and profile functions. Follow-up: ilp32f (ESP32-P4, H4, S31) is stacked on this branch as feat-ghidra-riscv-ilp32f and opens after it, as proposed in #7477.

Problem and expected behavior

  • Before: e_flags 0x1 (soft-float) was refused on ELF32 and ELF64.
  • After: ELF32 soft-float with a decoded Tag_RISCV_arch is admitted with __rea_ilp32; everything else is refused with a reason built from the lane table. Double-float behaviour and identity are unchanged.

Change and scope

  1. cc4e86e99: the D3 contract and its table-driven tests; no behaviour change.
  2. a11b43c35: admission: the .riscv.attributes scan (range validation's bounded reader, now one generic driver), the post-analysis script, and the handshake.
  3. 4a097051a: the real lane, and offline tests of its checks.
  4. 383b87cfb: values over 8 bytes by reference, as per-policy rows.
  5. bbe74105f, 656badf1f: main merges (317bf3fe2, d48e472fa); the two launcher refusals became fix: report provider admission failures as typed codes #8066 typed codes. 1515524b7: limitation tests check facts, not wording. d02fc6b78: stripped builds check return storage (review). d8ae325f1: docs record D3 as decided ([Design] Admit RISC-V ilp32 and ilp32f ELF in the Ghidra lane with a per-ABI calling-convention policy #7477).

Not included: ilp32f (EF_RISCV_FLOAT_ABI_SINGLE), the follow-up. With 4-byte floating-point entries, Ghidra 12.1.4 puts struct { float; int; } in a1:a0 instead of fa0 and a0. Also quad-float, RVE, TSO, ELF64 soft- or single-float, ET_DYN (#4811), and undecoded extensions.

Remaining cleanup, for separate PRs
  • parseRiscvAttributes repeats the attribute-section walk of MipsGnuAttributes.ts (jscpd: 16 lines), and feat(ghidra): verify and pin the 32-bit ARM (armhf) lane #1922 adds ARM's. One shared reader would change the MIPS reader.
  • ReaGhidraRiscvCallingConvention.java repeats the encode, parse and serialize steps of ReaGhidraMipsSoftFloat.java. Sharing them changes the MIPS lane, which needs its own real-Ghidra run.
  • Source-derived, not run on MIPS: Ghidra 12.1.4 encodes floating-point entries with storage="float" (observed on RISC-V), but the MIPS script removes entries whose metatype is float, so it removes only the rules. Its self-check still passes, because the rules decide typed storage.

Contract and boundary impact

  • Semantic owner and earliest changed stage: see the decision record; the earliest stage is target resolution (riscv.isa).
  • Contribution scope fit and linked maintainer decision: static analysis in the existing Ghidra RISC-V lane; no target execution, injection, mutation or protection recovery. No maintainer scope decision is required for static analysis in an existing lane (CONTRIBUTING); design decision D3 is recorded on [Design] Admit RISC-V ilp32 and ilp32f ELF in the Ghidra lane with a per-ABI calling-convention policy #7477, and maintainers can redirect it in review.
  • CLI and MCP/tool-catalog contract: no new inputs or tools. Previously refused targets are admitted. Refusals for other float ABIs come from the lane table and name the declared ABI, such as lp64. New launcher admission codes: existing_project_riscv_calling_convention (soft-float targets with REA_GHIDRA_PROJECT_PATH, whose project cannot run the post-analysis script) and riscv_calling_convention_scope (an internal guard).
  • Provider, bridge, target-format, or platform compatibility: Ghidra on Linux and macOS (RISC-V is outside Windows Ghidra P0). One new bridge post-script, with the policy id as its argument; one new session-info field and Program-info key for the policy.
  • Evidence, artifact, provenance, or reconstruction contract: soft-float profiles add riscv_elf.float_abi, riscv_elf.arch and riscv_calling_convention; session Evidence states the prototype and its counts. Double-float profiles are byte-identical (tested).
  • Target selection, authority, upstream behavior, and cleanup details: target resolution reads the section header table and at most 4,096 bytes of one attribute section of each RISC-V ELF, through the existing bounded reader. A malformed section leaves the declaration unavailable; other providers are unaffected.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: one bridge source in package.json files.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process. (Ghidra, as before.)
  • Inject instrumentation or run scripts/code. (REA's fixed Ghidra scripts, as before; no target execution.)
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: six test files; per-file coverage below.
  • Base reproduction or other evidence: source-derived, main refuses every float ABI except double-float (GhidraRiscvProfile.ts:68-72 at d48e472fa); observed, Ghidra 12.1.4's stock prototype reads the fixture's floating-point arguments from fa registers (below).
  • User-visible CLI/MCP output: below, from the CLI on this PR's tree.
  • Remaining proof gaps: no real-Ghidra run on macOS or Windows; no image built by GCC or ESP-IDF (the fixtures are LLVM builds with ESP-IDF's -march); A, F and D under ilp32 are admitted but not exercised; not checked whether older RISC-V toolchains write Tag_RISCV_arch (images without it are refused).
Per-file test coverage (counts on the head)
  • src/domain/riscvIsaDeclaration.test.ts (41 tests): every e_flags float ABI and its psABI name; the attribute parser on LLVM 21's exact bytes in both byte orders, the psABI's tag-parity rule, and 13 malformed sections refused; Tag_RISCV_arch strings from LLVM, GCC/ESP-IDF and non-canonical spellings.
  • src/ghidra/GhidraRiscvProfile.test.ts (49 tests): the lane-id and policy tables, and a check that docs/ghidra-riscv.md names every lane, policy, prototype and decoded extension; every refused declaration (ELF64 soft, single and quad; ELF32 single and quad; uninspected, absent and unavailable ISA declarations); ESP-IDF's bases admitted, and Zb*, Zcb, Zcmp, Zcmt, xesp*, RV32E, RV64 and non-canonical strings refused with the extensions named; the soft-float profile's exact parameters, and double-float profiles unchanged whatever the ISA declaration; a handshake with a fake bridge (the launch option, the outcome as a session limitation, a missing or unexpected report refused before any call, a policy mismatch refused before start, and caller-project history).
  • src/ghidra/GhidraSessionValues.test.ts: the report accepted exactly; 7 malformed reports refused.
  • tests/boundary/filesystem/riscvIsaDeclaration.test.ts (7 tests): hand-built ELF32 files with the attribute section beyond the 4 KiB probe: declared, absent, another vendor, two sections, an oversized section, and an undecoded extension.
  • tests/boundary/providers/ghidra/ghidraLauncher.test.ts: the post-script's place and argument, and its conflicts with PSP, MIPS soft-float, DOS, raw, DOL and existing projects, by admission code.
  • tests/conformance/ghidra/riscv-checks.test.ts (6 tests): the call-site oracle and the storage and pseudocode checks on recorded LLVM and Ghidra output. They refuse a moved argument, Ghidra's stock ilp32d model, long double storage without the by-reference rule, a wrong pointed-to word, and a stripped rea_riscv_abi_wide return that loses its high word. Recovered type names are not compared.
Base reproduction and a negative control

With Ghidra 12.1.4's stock prototype, the fixture's caller decompiles as:

fVar2 = rea_riscv_abi_pick(in_fa0,in_fa1,0x3fc00000);
dVar3 = rea_riscv_abi_wide((double)CONCAT44(extraout_var,fVar2),0);
(*rea_riscv_abi_callback)(extraout_fa0,extraout_fa1_00,0x41a40000);

Negative control for values over 8 bytes: without the by-reference rule, the prototype read rea_riscv_abi_quad's long double from a4:4,a3:4,a2:4,a1:4 and sel from a5; clang passes a pointer in a1 and sel in a2, as the derived prototype now reports.

CLI output on this PR's tree

For the ilp32 build of the fixture (-march=rv32imc_zicsr_zifencei), the committed profile:

{"language_id":"RISCV:LE:32:default","compiler_spec_id":"gcc",
 "riscv_support_lane":"elf32-exec-le-soft-float-generic-v1",
 "riscv_calling_convention":"ilp32-prototype-v1",
 "riscv_elf":{"elf_class":32,"byte_order":"little","type":2,"flags":1,
   "float_abi_double":false,"rvc_declared":true,"rve_declared":false,
   "tso_declared":false,"float_abi":"soft",
   "arch":"rv32i2p1_m2p0_c2p0_zicsr2p0_zifencei2p0_zmmul1p0"}}

An excerpt of the caller's pseudocode:

local_10 = rea_riscv_abi_pick(1.5,2.5,sel);
local_28 = rea_riscv_abi_split(1,2,3,4,5,6,local_c,7.25);
local_30 = rea_riscv_abi_pair((rea_riscv_abi_pair)0x4118000041080000,10.5);
rea_riscv_abi_quad((long_double *)&local_c0,(long_double *)&local_d0,local_c);
fVar1 = (*rea_riscv_abi_callback)(20.5,21.5,local_c);

The limitations include "RISC-V calling-convention outcome: 13 functions and 12 function definitions use __rea_ilp32." The same source built with ESP-IDF's optional _zcb_zcmp is refused before any provider starts:

{"provider_id":"ghidra","origin":"target","code":"architecture_unsupported",
 "reason":"Tag_RISCV_arch declares extensions outside the set this lane decodes: zcb, zcmp. Ghidra 12.1.4's generic RV32 language implements only m, a, f, d, c, zicsr, zifencei, zmmul, zaamo, zalrsc, zca, zcf, zcd with p-code; see docs/ghidra-riscv.md."}
Failed real runs on earlier heads

The first real run failed in the bridge. Untyped functions have unassigned return storage, so the script's storage check threw and wrote no report, and REA refused the session as designed. The check now allows unassigned storage for functions and stays strict for the prototype self-check. The next two runs failed in the verifier: inspect_native_api Evidence comes from the rea-workflow provider, and a stripped build also records residual unknowns without a profile. The verifier now checks each by its provider.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

The head d8ae325f1 changes only the D3 wording in docs/ghidra-riscv.md; npm run docs:check and format:check passed on it.

d02fc6b78 checks the stripped build's return storage on top of 656badf1f, which merges main d48e472fa. The other checks ran on the same tree as 656badf1f.

  • macOS arm64 (Darwin 25.5.0), Node 24.22.1, npm 11.19.1:
    • On d02fc6b78: npm run check:fast, format:check, docs:check and verify:module-boundaries — passed. npx knip — no findings. npm run jscpd — 3.57% (threshold 4%). npm run test:focused -- the RISC-V conformance checks, the RISC-V profile tests and the README consistency test — 64 passed.
    • On the same tree as 656badf1f: the same static checks passed, and npm run test:focused -- 22 files (the 6 test files this PR changes and tests of the code it shares with main's latest changes) — 893 passed, 4 skipped (Windows-only).
  • Real Ghidra 12.1.4 in a Debian 13 container (Linux x86_64; OpenJDK 21.0.12, Node 24.22.1, LLVM 19.1.7; npm ci --ignore-scripts), on d02fc6b78 and before that on the same tree as 656badf1f:
    • npm run verify:ghidra:bridge-sources — passed: all 11 bridge sources compile against Ghidra's 195 jars.
    • npm run verify:ghidra:riscv — passed: "mocked": false, cleanup complete, process lineage verified with no descendants. The typed ilp32 build has the compiler's storage at all ten calls, the stripped build returns where the typed build does, and other float ABIs are refused.
    • npm run verify:ghidra:mips — not run: on main d48e472fa it fails at its carved fixture before any soft-float code runs; the queued MIPS verify fix repairs that.
  • Both hosts' installs differ from the lockfile only in the transitive fast-uri 3.1.8 and qs 6.16.0 (lockfile: 3.1.9 and 6.16.1).
  • Not run: real Ghidra on macOS or Windows (the macOS host has no Ghidra 12.1.4, only JDK 25); ilp32f.
Lane results per fixture on d02fc6b; an earlier head's wider run
  • RV32 and RV64 double-float: the unchanged lanes and profiles. The RV32 image relabelled soft-float (0x1) is admitted over MCP and the CLI as elf32-exec-le-soft-float-generic-v1 with its own ISA string; RV64 0x1 is refused ("soft-float ABI (lp64)"); 0x80000005 is refused on both.
  • RV32 ilp32, typed (rv32imc_zicsr_zifencei): the soft-float lane and ilp32-prototype-v1; fence.i and csrr decode; every inspect_native_api prototype uses __rea_ilp32 with the policy's storage (for example an unaligned double at a2:4,a1:4, the split at Stack[0x0]:4,a7:4, and the long double call at a0:4 (auto), a1:4 and a2:4); the caller's pseudocode passes the source constants; 13 functions and 12 function definitions use the prototype. Relabelled single-float (0x3) and 0x80000001 are refused.
  • RV32 ilp32, stripped: every allocated section identical to the typed build; one integer word per parameter location. Returns are in the typed build's registers: a0:4, or a1:4,a0:4 for the five 8-byte results. The two results returned through caller memory have no return storage (<VOID>). 13 functions and 0 function definitions.
  • Call-site oracle: LLVM 19.1.7 llvm-objdump of the typed caller places every expected word for all ten calls, including the memory behind both by-reference pointers.
  • Snapshots save and replay, CLI and MCP agree, and source bytes are unchanged for all four fixtures. The lanes gave the same results on the same tree as 656badf1f.

An earlier head, 383b87cfb, also passed npm run test:changed (on 990a82dee, with the same TypeScript): 393 files, 7,092 passed, 7 skipped.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Admission widens, and refusal texts for other float ABIs change.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra 12.1.4 on Linux x86_64 only; no Hopper.
  • Package or release metadata impact: one bridge source.
  • Security, privacy, process, or containment review: no new authority.

Author readiness

Human owner: @Entrpi

  • 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.
  • 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.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Decision D3 (morluto#7477), provisional: admit ELF32 soft-float (ilp32) RISC-V
images through a lane that keeps the pinned RISCV:LE:32:default language and
corrects the calling convention in the bridge.

This commit is the contract only; admission is unchanged.

- The domain owns the e_flags float-ABI vocabulary and parses
  .riscv.attributes and Tag_RISCV_arch into a declared, absent or
  unavailable ISA declaration.
- The Ghidra profile owns the lane table (class and float ABI), lane ids
  built from fields, the ilp32-prototype-v1 policy and its __rea_ilp32
  prototype, and the extensions Ghidra 12.1.4 decodes with p-code.
- The session handshake accepts the bridge's calling-convention report.
- docs/ghidra-riscv.md keeps the decision record and per-ABI policies for
  ilp32 and ilp32f; a test keeps it in step with the tables.
- tests/conformance/c/riscv-float-abi.c is the source the policies were
  measured on.
ESP32-C2, C3, C5, C6, C61, H2 and H21 builds are ELF32 soft-float (ilp32)
images, which the RISC-V lane refused at its double-float check. Ghidra
12.1.4's generic RV32 compiler specification models ilp32d, so its stock
prototype would read float and double arguments from fa0-fa7.

- Target resolution reads the one SHT_RISCV_ATTRIBUTES section through the
  same bounded ELF declaration reader as range validation, and records
  Tag_RISCV_arch as declared, absent or unavailable.
- Admission selects a lane from the class and float-ABI table. The soft-float
  lane also requires an RV32I Tag_RISCV_arch that declares only extensions
  Ghidra decodes with p-code; the refusal names any others (Zcb, Zcmp, Zcmt,
  Zb*, xesp*).
- Soft-float profiles commit float_abi, arch, riscv_calling_convention
  ilp32-prototype-v1 and the lane elf32-exec-le-soft-float-generic-v1.
  Double-float profiles are unchanged.
- ReaGhidraRiscvCallingConvention.java runs after analysis. It derives
  __rea_ilp32 from the default prototype without floating-point entries and
  rules, with fs0-fs11 killed by calls, self-checks its storage and assigns
  it to every non-thunk function, external function and function
  definition. Its report is written last.
- The provider client requires that report exactly when the profile commits
  the policy, before any operation, and keeps it as session limitations and
  caller-project history.

ELF32 single-float (ilp32f), quad-float and ELF64 soft- or single-float
images stay refused, now with a reason built from the lane table.
verify:ghidra:riscv now also builds tests/conformance/c/riscv-float-abi.c
with ESP32-C3's -march=rv32imc_zicsr_zifencei -mabi=ilp32, typed with DWARF
and linked again with --strip-all. Every allocated section of the stripped
image must keep its address and bytes.

- riscv-checks.mjs holds the ilp32 storage of each fixture function together
  with the words the compiler's call site writes there. An LLVM objdump
  reading of the caller must find every word at its stated location: an
  unaligned named double, the a7/stack split, two floats in an integer pair,
  a large structure by reference, aligned variadic pairs and an indirect
  call.
- Through CLI and stdio MCP, the soft-float builds must report the soft-float
  lane and ilp32-prototype-v1, __rea_ilp32 with exactly that storage (one
  integer word per location when stripped), caller pseudocode that passes the
  source constants and names no floating-point register, the prototype
  outcome in retained Evidence, and decoded fence.i and csrr.
- The RV32 double-float image relabelled as soft-float, refused before, is
  admitted through the new lane. RV64 soft-float, single-float and unsupported
  bits are refused with their reasons.
- riscv-checks.test.ts runs the checks offline against recorded LLVM and
  Ghidra output, including Ghidra's stock ilp32d prototypes as a negative
  control.
The psABI passes any value wider than 2 x XLEN by reference, scalars
included. __rea_ilp32 converted only structures and unions over 8 bytes to
pointers, so a long double (16 bytes) was joined into a1-a4. Measured on
Ghidra 12.1.4, rea_riscv_abi_quad(long double value, int sel) read value
from a4:4,a3:4,a2:4,a1:4 and sel from a5, where clang passes a pointer in
a1 and sel in a2.

- ReaGhidraRiscvCallingConvention.java now has one derivation driven by a
  per-policy row (floating-point entry size, preserved floating-point
  registers). Every policy inserts a rule before the input list's final
  join that converts any value of 9 bytes or more to a pointer; a return
  that size already becomes a caller buffer. The self-check requires a
  16-byte value to pass by reference.
- The fixture gains rea_riscv_abi_quad. The call-site oracle now checks the
  words the by-reference pointers point at, for the large structure and the
  long double, and the recorded data comes from an LLVM 19 build.
- docs/ghidra-riscv.md: the decision record and the ilp32 policy row.

ilp32-prototype-v1 keeps its id: no release carries it yet.
The limitation tests froze a full explanatory sentence, the note count and
array positions, so a harmless rewording failed them: the pattern Greptile
flagged on morluto#7486. Assert the facts the notes must carry instead: the pinned
language, the static-linkage boundary, one note naming the declared ABI,
the ABI the pinned language models and the prototype REA applies, and the
declared ISA.
Takes main d48e472, which includes the squash merges of morluto#7481-morluto#7485.

Conflict, resolved: GhidraRiscvProfile.test.ts imports this branch's lane
and policy tables plus ghidraRiscvUnsupportedReason, which morluto#7484's
refusal-table assertions use; embedded-integration holds the same list.
morluto#7484's readback test merges cleanly and appears once.
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] No new merge-blocking issue was found in the documentation-only update.

Summary

Adds an ELF32 RISC-V soft-float lane with a derived __rea_ilp32 calling convention.

  • Supported ELF32 soft-float images enter the Ghidra RISC-V lane.
  • Ghidra decompiles admitted ilp32 images with integer-register argument and return placement.

Reviews (3) · Last reviewed commit: "docs(ghidra): record decision D3 as deci..." · Reviewed by Greptile

The stripped branch of assertRiscvIlp32Storage compared parameter storage
only, so an inferred return that lost the high word of a register pair,
such as rea_riscv_abi_wide at a0:4 instead of a1:4,a0:4, still passed.

Stripped returns must now use the typed build's storage, or none when the
result goes through caller memory. Recovered type names are still not
compared: a test accepts other type names and refuses the dropped high word.
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
@Entrpi
Entrpi marked this pull request as ready for review October 31, 2026 00:31
@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-31T00:31:30.263781Z
We couldn’t complete this review. Comment @codex review to try again.
d8ae325 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto merged commit e669365 into morluto:main Oct 31, 2026
49 checks passed
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
e6d0618 (morluto#8228) is the parent of morluto#8229's squash e669365, which the next merge records. The merge is clean.
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
Recorded with -s ours: this branch already holds morluto#8229's final head d8ae325, and git patch-id --stable of the squash equals that of d8ae325's own patch (7bc824d8360616b7).
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
Take main 6e9ee97. morluto#8228's ESP flash inputs join D1's load selection:
resolver, session and CLI options carry `loadSelection` and `espFlash`,
and `formatHint` comes from the selection. `inspect-artifact` and
`extract-artifact` now pass `--target-format esp-flash-image` as a load
selection; built from spreads, the old `formatHint` key compiled but was
dropped. The open_binary description keeps D1's M-profile sentence and
morluto#8361's investigation-record ending. Tests from main move to D1's inputs,
as embedded-integration did: morluto#7481's raw vocabulary target carries
`rawLoad`, morluto#8228's flash resolver tests pass `loadSelection`, morluto#8229's raw
scope case names its entry, and the pairing grid adds esp-flash-image's
four rows while the other sixteen keep d6f88be's hash.
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 31, 2026
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 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 enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants