keystone icon indicating copy to clipboard operation
keystone copied to clipboard

RISC-V encoding bug

Open petabyt opened this issue 3 months ago • 3 comments

Some if statements in RISCVAsmBackend.cpp were intended to have multiple statements, but are missing braces. This causes the beq instruction to be encoded as -1 (FF FF FF FF)

https://github.com/keystone-engine/keystone/blob/fb92f32391c6cced868252167509590319eeb58b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp#L201

petabyt avatar Sep 01 '25 21:09 petabyt

That code is from LLVM 3.9.0, LLVM's current release is 21.1.0. This project really should update LLVM.

RossComputerGuy avatar Sep 07 '25 20:09 RossComputerGuy

I don't see any problem with the old LLVM, it's just that the person who backported RISC-V support made a dumb mistake lol

https://github.com/keystone-engine/keystone/pull/549/files

petabyt avatar Sep 08 '25 04:09 petabyt

Says:

  • adds the support for RISC-V architecture (refers to #491) from LLVM 9.0.1 version - the first official release of RISC-V to LLVM

Surely, the RISC-V support from LLVM 9 isn't as stable as something like 21. That's about 6 years of improvements.

RossComputerGuy avatar Sep 08 '25 06:09 RossComputerGuy