[PR #4811] feat(ghidra): admit RISC-V position-independent executables (#4487) #6420

Open
opened 2026-10-31 01:14:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4811
Author: @abhay-2108
Created: 10/17/2026
Status: 🔄 Open

Base: main ← Head: feat/ghidra-riscv-pie-4487


📝 Commits (1)

  • a948219 feat(ghidra): admit RISC-V position-independent executables (#4487)

📊 Changes

10 files changed (+596 additions, -313 deletions)

View changed files

📝 docs/ghidra-riscv.md (+35 -25)
📝 scripts/verify-real-ghidra-riscv.mjs (+294 -229)
📝 src/application/BinaryTargetResolver.ts (+21 -10)
📝 src/domain/binaryTargetTypes.ts (+1 -0)
📝 src/domain/elfDeclaredRanges.ts (+25 -5)
📝 src/domain/elfProgramHeader.ts (+2 -0)
📝 src/ghidra/GhidraRiscvProfile.test.ts (+108 -2)
📝 src/ghidra/GhidraRiscvProfile.ts (+47 -32)
📝 tests/boundary/filesystem/elfDeclaredRanges.test.ts (+22 -0)
📝 tests/conformance/ghidra/riscv-fixture.mjs (+41 -10)

📄 Description

Summary

Fixes #4487

Admits little-endian RISC-V ELF32 and ELF64 position-independent executables (ET_DYN with PT_INTERP) into the pinned generic Ghidra lane (RISCV:LE:{32,64}:default + gcc). Most Linux distribution userlands (such as Debian trixie riscv64) build almost all executables as PIE and were previously refused by the lane's ET_EXEC-only check.

Shared libraries (ET_DYN without PT_INTERP) remain refused with a dedicated reason noting that shared libraries require separate load verification.

Key Changes

  • Target Resolution: Detects PT_INTERP in ELF program headers and flags hasInterpreter: true in ElfFamilyMetadata (src/domain/binaryTarget.ts, src/application/BinaryTargetResolver.ts).
  • Ghidra RISC-V Profile: Admits little-endian ET_DYN images having hasInterpreter: true under lane identities elf32-pie-le-double-float-generic-v1 and elf64-pie-le-double-float-generic-v1 (src/ghidra/GhidraRiscvProfile.ts).
  • Profile Parameters: Emits has_interpreter: true, load_model: "pie", and the load base Ghidra applied ("0x10000" for RV32, "0x100000" for RV64) in riscv_elf.
  • Refusal Preservation: Explicitly refuses ET_DYN targets lacking PT_INTERP with a distinct refusal reason.
  • Documentation: Updated docs/ghidra-riscv.md with PIE admission boundary, refusal table, and Evidence semantics.

Validation Performed

  • vitest run src/domain/binaryTarget.riscv.test.ts src/ghidra/GhidraRiscvProfile.test.ts (31 tests passed)
  • vitest run src/domain/binaryTarget.test.ts (48 tests passed)
  • tsc --noEmit (0 errors)
  • node scripts/ci/static-check-report.mjs lint (0 errors)
  • node scripts/verify-module-boundaries.mjs (2054 files passed)
  • oxfmt --check (All matched files pass)

Author readiness

Human owner: @abhay-2108

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4811 **Author:** [@abhay-2108](https://github.com/abhay-2108) **Created:** 10/17/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/ghidra-riscv-pie-4487` --- ### 📝 Commits (1) - [`a948219`](https://github.com/morluto/rea/commit/a948219e7b83ac39157288a117532ff13bb3bc81) feat(ghidra): admit RISC-V position-independent executables (#4487) ### 📊 Changes **10 files changed** (+596 additions, -313 deletions) <details> <summary>View changed files</summary> 📝 `docs/ghidra-riscv.md` (+35 -25) 📝 `scripts/verify-real-ghidra-riscv.mjs` (+294 -229) 📝 `src/application/BinaryTargetResolver.ts` (+21 -10) 📝 `src/domain/binaryTargetTypes.ts` (+1 -0) 📝 `src/domain/elfDeclaredRanges.ts` (+25 -5) 📝 `src/domain/elfProgramHeader.ts` (+2 -0) 📝 `src/ghidra/GhidraRiscvProfile.test.ts` (+108 -2) 📝 `src/ghidra/GhidraRiscvProfile.ts` (+47 -32) 📝 `tests/boundary/filesystem/elfDeclaredRanges.test.ts` (+22 -0) 📝 `tests/conformance/ghidra/riscv-fixture.mjs` (+41 -10) </details> ### 📄 Description ## Summary Fixes #4487 Admits little-endian RISC-V ELF32 and ELF64 position-independent executables (`ET_DYN` with `PT_INTERP`) into the pinned generic Ghidra lane (`RISCV:LE:{32,64}:default` + `gcc`). Most Linux distribution userlands (such as Debian trixie riscv64) build almost all executables as PIE and were previously refused by the lane's `ET_EXEC`-only check. Shared libraries (`ET_DYN` without `PT_INTERP`) remain refused with a dedicated reason noting that shared libraries require separate load verification. ## Key Changes - **Target Resolution**: Detects `PT_INTERP` in ELF program headers and flags `hasInterpreter: true` in `ElfFamilyMetadata` (`src/domain/binaryTarget.ts`, `src/application/BinaryTargetResolver.ts`). - **Ghidra RISC-V Profile**: Admits little-endian `ET_DYN` images having `hasInterpreter: true` under lane identities `elf32-pie-le-double-float-generic-v1` and `elf64-pie-le-double-float-generic-v1` (`src/ghidra/GhidraRiscvProfile.ts`). - **Profile Parameters**: Emits `has_interpreter: true`, `load_model: "pie"`, and the load base Ghidra applied (`"0x10000"` for RV32, `"0x100000"` for RV64) in `riscv_elf`. - **Refusal Preservation**: Explicitly refuses `ET_DYN` targets lacking `PT_INTERP` with a distinct refusal reason. - **Documentation**: Updated `docs/ghidra-riscv.md` with PIE admission boundary, refusal table, and Evidence semantics. ## Validation Performed - `vitest run src/domain/binaryTarget.riscv.test.ts src/ghidra/GhidraRiscvProfile.test.ts` (31 tests passed) - `vitest run src/domain/binaryTarget.test.ts` (48 tests passed) - `tsc --noEmit` (0 errors) - `node scripts/ci/static-check-report.mjs lint` (0 errors) - `node scripts/verify-module-boundaries.mjs` (2054 files passed) - `oxfmt --check` (All matched files pass) ## Author readiness Human owner: @abhay-2108 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6420
No description provided.