Repository navigation
feat(ghidra): admit RISC-V position-independent executables (#4487) - #4811
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The latest changes appear safe to merge and fix the numbered soft-float PIE finding. SummaryAdds RISC-V double-float PIE admission at both widths while keeping shared libraries and soft-float PIE refused.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read ELF declarations] --> B[Retain PT_INTERP presence]
B --> C{Load model and float ABI}
C -->|ET_EXEC with admitted ABI| D[Pinned generic RISC-V language]
C -->|ET_DYN with PT_INTERP and double-float| D
C -->|ET_DYN without PT_INTERP| E[Refuse shared library]
C -->|Soft-float PIE| F[Refuse unverified combination]
D --> G[Commit lane and analysis profile]
Reviews (12) · Last reviewed commit: "fix(ghidra): restrict PIE admission to v..." · Reviewed by Greptile |
338325a to
3942474
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
3942474 to
1239195
Compare
|
The review feedback has been addressed and verified with unit tests in 9bdbfa3. The PR is ready for review. Note on CI: The failures in |
|
TL;DR: It admits a real Debian riscv64 PIE and the load looks right. Shared libraries are still refused, as the PR says. Thanks, abhay-2108. Note that GitHub currently shows the branch as conflicting with Build: this PR's head Target:
Not checked: other coreutils binaries, decompilation quality, and relocation application beyond the section placement above. |
9bdbfa3 to
df1a47b
Compare
df1a47b to
382abe2
Compare
|
TL;DR: Retested the new head Build: this PR's head Targets: Debian trixie
Not checked: decompilation quality and relocation application beyond section and entry placement. |
…4487) Admit little-endian RISC-V ELF32 and ELF64 position-independent executables (ET_DYN with PT_INTERP) into the pinned generic Ghidra lane. - Collect `PT_INTERP` during the existing validated ELF table walk in `validateElfDeclaredRanges` and record `hasInterpreter` in target metadata, supporting arbitrary table offsets and extended program counts without duplicate scanning. - Admit ET_DYN images when `hasInterpreter` is present under lane identities `elf32-pie-le-double-float-generic-v1` and `elf64-pie-le-double-float-generic-v1`. - Preserve refusal for non-PIE ET_DYN targets (shared libraries without PT_INTERP) explaining that shared libraries require separate load verification. - Record load model facts (`load_model: "pie"`, `expected_default_image_base: "0x10000"` or `"0x100000"`, `has_interpreter: true`) in `riscv_elf` analysis profile parameters. - Record default image base analysis coordinates limitation for PIE targets. - Update `docs/ghidra-riscv.md` with PIE admission boundary and evidence semantics. - Add unit tests for PT_INTERP collection, high-offset program headers, and PIE profile resolution. - Add PIE fixture generation capability to `tests/conformance/ghidra/riscv-fixture.mjs` and pass `-Wl,-pie` to ensure bare-metal drivers generate ET_DYN. - Extend `scripts/verify-real-ghidra-riscv.mjs` to test both ET_EXEC and ET_DYN. Fixes morluto#4487
382abe2 to
a948219
Compare
Thanks for testing across the Debian coreutils binaries ( I've rebased the branch onto latest |
|
Hey @abhay-2108, thanks for putting this together, the addition looks useful. What's left: it has merge conflicts with main in |
…-4487 # Conflicts: # docs/ghidra-riscv.md # scripts/verify-real-ghidra-riscv.mjs # src/application/BinaryTargetResolver.ts # src/ghidra/GhidraRiscvProfile.test.ts # src/ghidra/GhidraRiscvProfile.ts # tests/conformance/ghidra/riscv-fixture.mjs
|
Hi @morluto , main has been merged into the branch, all conflicts are resolved, and review feedback on test assertions/errors has been addressed. All CI checks are green-ready for your final review and merge! |
Summary
Fixes #4487
Admits little-endian RISC-V ELF32 and ELF64 position-independent executables (
ET_DYNwithPT_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'sET_EXEC-only check.Shared libraries (
ET_DYNwithoutPT_INTERP) remain refused with a dedicated reason noting that shared libraries require separate load verification.Key Changes
PT_INTERPin ELF program headers and flagshasInterpreter: trueinElfFamilyMetadata(src/domain/binaryTarget.ts,src/application/BinaryTargetResolver.ts).ET_DYNimages havinghasInterpreter: trueunder lane identitieself32-pie-le-double-float-generic-v1andelf64-pie-le-double-float-generic-v1(src/ghidra/GhidraRiscvProfile.ts).has_interpreter: true,load_model: "pie", and the load base Ghidra applied ("0x10000"for RV32,"0x100000"for RV64) inriscv_elf.ET_DYNtargets lackingPT_INTERPwith a distinct refusal reason.docs/ghidra-riscv.mdwith 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