Skip to content

RISCV compressed instruction mode renamed between 5.x and 6.x #2977

Description

@peace-maker

Work environment

Questions Answers
System Capstone runs on OS/arch/bits Ubuntu x86_64
Capstone module affected riscv
Source of Capstone pip
Version/git commit 6.0.0a9

Expected behavior

Code using the CS_MODE_RISCVC constant in capstone 5 fails to compile against capstone 6. The constant was renamed to CS_MODE_RISCV_C in #2756

V5:

CS_MODE_RISCV32 = 1 << 0, ///< RISCV RV32G
CS_MODE_RISCV64 = 1 << 1, ///< RISCV RV64G
CS_MODE_RISCVC = 1 << 2, ///< RISCV compressed instructure mode

V6:

CS_MODE_RISCV32 = 1 << 0, ///< RISCV RV32G
CS_MODE_RISCV64 = 1 << 1, ///< RISCV RV64G
CS_MODE_RISCV_C = 1 << 2, ///< RISCV compressed instructure mode

There is no CAPSTONE_RISCV_COMPAT_HEADER define to bring back the old name similar to the one for Aarch64 and systemz. The code is expected to compile.

cstest has a legacy mapping for the old name

{ .str = "CS_MODE_RISCV32", .val = CS_MODE_RISCV32 },
{ .str = "CS_MODE_RISCV64", .val = CS_MODE_RISCV64 },
{ .str = "CS_MODE_RISCVC", .val = CS_MODE_RISCV_C },
{ .str = "CS_MODE_RISCV_A", .val = CS_MODE_RISCV_A },
{ .str = "CS_MODE_RISCV_C", .val = CS_MODE_RISCV_C },

Actual behavior

The CS_MODE_RISCVC name is not found, compilation aborts. Similarly in the Python bindings.

Steps to reproduce the behavior

(Testing with Python due to JonathanSalwan/ROPgadget#223)

from capstone import *
print(CS_MODE_RISCVC)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions