Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable bit-manipulation extensions to RISC-V #2544

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

OBarronCS
Copy link

@OBarronCS OBarronCS commented Feb 17, 2025

In reference to #2539, this PR enables certain RISC-V ISA extensions in assembly passed to the asm function in pwntools. It simply adds the zba, zbb, zbc, and zbs extension strings to CLI arguments passed to the assembler.

There is a long list of other ISA extensions outlined in this doc - https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html, but these 4 were chosen purely because they are general purpose and I happened to have run into them (many of the other ones are related to increasing performance of cryptographic functions or are SIMD-related).

The original issue mentions the possibility of exposing more functionality in the asm() function to allow the user to have more control over the assembler/compile process. In this case, as mentioned by @Arusekk in #2539, this is not needed. Currently, examples of where this would be nice don't immediately come to mind.

@Arusekk
Copy link
Member

Arusekk commented Feb 21, 2025

Is gbc not enough? The full B extension seems safe to enable, as well as V I guess (no plain instruction should get sneakily converted to a vector instruction I guess).

@OBarronCS
Copy link
Author

I'm unable to find any information referencing the use of b to enable the B extension. It outputs the following error:

Error: cannot find default versions of the ISA extension `b'

I think adding the v extension would work, and added it in the latest commit (and removed zbc which wasn't actually considered a B extension, see here riscv/riscv-b#5 (comment)). Although

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants