Skip to content

Updating the project RISC-V asm and analysis capabilities#5482

Merged
notxvilka merged 3 commits into
rizinorg:devfrom
moste00:feature/update_capstone_riscv
Feb 16, 2026
Merged

Updating the project RISC-V asm and analysis capabilities#5482
notxvilka merged 3 commits into
rizinorg:devfrom
moste00:feature/update_capstone_riscv

Conversation

@moste00

@moste00 moste00 commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

As per #5275, this PR builds on the refactored Capstone RISCV plugin in capstone-engine/capstone#2756 and propagates the change to Rizin, adding lots of Rizin-specific capbilities.

(1- AI Disclosure) I use Gemini CLI in the context of the codebase, mostly or almost exclusively for read-only type of usage: as an intelligent search engine to navigate and query the codebase, I almost always reject edit requests by it. I also use Claude Web for general questions, routine text editing, and other context-free tasks.

(2- Diff Density) I expect most of the changes to be concentrated heavily in the analysis-riscv-cs.c file, because this file wasn't updated in 5 years and is in heavy need for updates to take advantage of the new Capstone module, however the first state of this PR mostly focuses on minimal changes to get it to compile and pass tests, most of the diff is instead build file glue and tests modification.

(3- Temp Changes) Some changes are temporary and won't survive the merging of this PR, for example a legacy GNU plugin is kept as-is to reduce diff noise but just renamed to riscv.gnu so it's not the default (and the RISCV plugin is renamed to riscv from riscv.cs), and some build system logic is added so that we can build with a local development version of Capstone instead of a published release.

Test plan

With the exception of relevant tests under db/esil, all old tests are relevant and will be kept and made to pass. New tests must be added from a variety of source to ensure the new capabilities. This section is evolving as more tests are added.

NOTE, to any reviewer running locally: Change the local path in subprojects/capstone-capstone-riscv-updated.wrap to a Capstone archive containing the RISCV updates.

Closing issues

** Depedents **

Depends-on: rizinorg/rizin-testbins#223
Depends-on: #5666
Depends-on: capstone-engine/capstone#2756

Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p_gnu/analysis/analysis_riscv_gnu.c Outdated
Comment thread librz/arch/meson.build Outdated
Comment thread librz/arch/p/asm/asm_riscv_cs.c
@wargio
wargio marked this pull request as draft October 27, 2025 04:42
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread subprojects/capstone-capstone-riscv-updated.wrap Outdated
@github-actions github-actions Bot added the API label Nov 10, 2025
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch from 7f4c55c to 1e5730c Compare November 29, 2025 20:12
Comment thread librz/include/rz_analysis.h
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch from b2c38f8 to 4e63a52 Compare December 21, 2025 02:45
@notxvilka notxvilka changed the title Updating the project RISCV asm and analysis capabilities Updating the project RISC-V asm and analysis capabilities Dec 21, 2025
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c
Comment thread librz/arch/p/asm/asm_riscv_cs.c Outdated
Comment thread librz/bin/format/elf/elf_relocs_patching.c Outdated
Comment thread librz/bin/format/elf/elf_relocs_patching.c Outdated
Comment thread librz/bin/format/elf/elf_relocs_patching.c Outdated
Comment thread librz/bin/p/bin_elf.inc Outdated
Comment thread librz/include/rz_analysis.h
@moste00
moste00 marked this pull request as ready for review December 21, 2025 19:45

@notxvilka notxvilka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please don't forget to remove the old GNU plugin. I recommend squashing it into two commits:

  • one is to remove old RISC-V GNU plugins
  • second is to add new plugins

@Rot127 Rot127 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just recognized that this whole effort means the RISCV features in Capstone are not well enough defined I think. Rizin is the first tool using the new CS plugin and implements a work around for the features? This is not a good sign.

@moste00 I didn't recognized this when we talked in Mattermost, but I think we should at least consider using alternatives.

cc @notxvilka @wargio

Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/analysis/analysis_riscv_cs.c Outdated
Comment thread librz/arch/p/asm/asm_riscv_cs.c Outdated
Comment thread librz/arch/p/arch_riscv_cs.c Outdated
Comment thread librz/bin/format/elf/elf_info.c
Comment thread sys/riscv_extension_parser_generator.py
Comment thread librz/arch/p/arch_riscv_cs.c
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch from 7d7e1a1 to 2483401 Compare February 8, 2026 01:04
Comment thread subprojects/capstone-capstone-riscv-updated.wrap Outdated
Comment thread meson_options.txt Outdated
Comment thread subprojects/packagefiles/capstone-riscv-updated/meson.build
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch 7 times, most recently from a93003a to 62ecb00 Compare February 11, 2026 23:22
Comment thread librz/bin/format/elf/elf_info.c Outdated
Comment thread librz/bin/format/elf/elf_info.c
Comment thread librz/bin/format/elf/elf_info.c
Comment thread librz/arch/p/arch_riscv_cs.c Outdated
Comment thread librz/arch/p/arch_riscv_cs.c Outdated
Comment thread librz/arch/p/arch_riscv_extension_parser.inc
Comment thread librz/bin/format/elf/elf_relocs_patching.c
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch 5 times, most recently from 32f34ed to b4b1420 Compare February 15, 2026 22:28
notxvilka

This comment was marked as resolved.

@notxvilka

Copy link
Copy Markdown
Contributor

@moste00 please:

  1. rebase to resolve conlicts
  2. fix the bindgen linter
  3. point v6 and next to the latest commits/releases

Then we can merge

@moste00
moste00 force-pushed the feature/update_capstone_riscv branch from b4b1420 to d85fd18 Compare February 16, 2026 16:10
Comment thread librz/bin/format/elf/elf_info.c Outdated
@moste00
moste00 force-pushed the feature/update_capstone_riscv branch from d85fd18 to 85b3930 Compare February 16, 2026 17:50
@codecov

codecov Bot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.71010% with 925 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.82%. Comparing base (719e410) to head (85b3930).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
librz/arch/p/arch_riscv_extension_parser.inc 11.36% 556 Missing and 91 partials ⚠️
librz/arch/p/analysis/analysis_riscv_cs.c 78.52% 83 Missing and 10 partials ⚠️
librz/bin/format/elf/elf_relocs_patching.c 65.70% 78 Missing and 5 partials ⚠️
librz/arch/p/arch_riscv_cs.c 59.15% 46 Missing and 12 partials ⚠️
librz/bin/format/elf/elf_info.c 46.15% 24 Missing and 11 partials ⚠️
librz/arch/p/analysis/analysis_riscv_utils.h 85.00% 6 Missing and 3 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/arch/p/asm/asm_riscv_cs.c 80.00% <100.00%> (+80.00%) ⬆️
librz/bin/p/bin_elf.inc 67.54% <ø> (ø)
librz/include/rz_analysis.h 77.77% <ø> (ø)
librz/arch/p/analysis/analysis_riscv_utils.h 85.00% <85.00%> (ø)
librz/bin/format/elf/elf_info.c 68.34% <46.15%> (-1.39%) ⬇️
librz/arch/p/arch_riscv_cs.c 59.15% <59.15%> (ø)
librz/bin/format/elf/elf_relocs_patching.c 29.86% <65.70%> (+4.38%) ⬆️
librz/arch/p/analysis/analysis_riscv_cs.c 73.32% <78.52%> (+73.32%) ⬆️
librz/arch/p/arch_riscv_extension_parser.inc 11.36% <11.36%> (ø)

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 719e410...85b3930. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@notxvilka
notxvilka merged commit 1587651 into rizinorg:dev Feb 16, 2026
46 of 47 checks passed
@notxvilka notxvilka mentioned this pull request Feb 17, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants