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

Capstone v6 update (without Mips) #4662

Merged
merged 27 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a835900
Handle ldr case without base register.
Rot127 Sep 28, 2024
ca57672
Fix memory leaks
Rot127 Oct 5, 2024
1b6ad42
Add Capstone v6 and bump next to newest commit.
Rot127 Oct 6, 2024
12d5512
Fix tests.
Rot127 Oct 6, 2024
cc3e8c5
Change to AArch64 compatibility header
Rot127 Oct 6, 2024
738589d
Fix more CSv6 changes in naming
Rot127 Oct 6, 2024
acf7eea
Fix CS v6 Mips related build issues.
Rot127 Oct 6, 2024
7fba09d
Fix CS v6 SystemZ related build issues.
Rot127 Oct 6, 2024
ca75bc2
Fix SystemZ analysis tests after CSv6 update
Rot127 Oct 6, 2024
4ed3f5e
Mark all failing MIPS tests as broken.
Rot127 Oct 6, 2024
054fe72
Fix Sparc tests.
Rot127 Oct 6, 2024
b7eca1f
Mark M68k tesst broken.
Rot127 Oct 6, 2024
4e39213
Handle op.size == 0 case.
Rot127 Oct 6, 2024
0b66f5f
Fix TriCore tests.
Rot127 Oct 6, 2024
386a7ad
Run clang-format
Rot127 Oct 6, 2024
ae1ed87
Revert "Fix TriCore tests."
Rot127 Oct 9, 2024
882df55
Bump Caspstone to newest next.
Rot127 Oct 21, 2024
3c5b785
Fix tests.
Rot127 Oct 21, 2024
3bca898
Add Capstone v4 again to docs
Rot127 Oct 21, 2024
9964267
Mark Mips tests broken
Rot127 Oct 21, 2024
30e713f
Don't allow v6 CI job for CS v6 to fail.
Rot127 Oct 21, 2024
bb50ad2
Build Capstone next with SystemZ and print warning if it couldn't ini…
Rot127 Oct 21, 2024
5ce6672
Bump Ubuntu runner to 24.04.
Rot127 Oct 21, 2024
decc9a5
Fix TriCore asm tests after https://github.com/capstone-engine/capsto…
Rot127 Oct 21, 2024
7da6c8e
Revert "Bump Ubuntu runner to 24.04."
Rot127 Oct 21, 2024
8b168fa
Add link to issue
Rot127 Oct 21, 2024
470ef0a
Bump to newest Capstone next
Rot127 Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ jobs:
timeout: 45
cflags: "-Wno-cpp"
allow_failure: true
- name: capstone-v6
os: ubuntu-22.04
build_system: meson
compiler: gcc
meson_options: -Dbuildtype=release -Duse_capstone_version=v6 --werror
run_tests: false
enabled: ${{ (github.event_name != 'pull_request' || contains(github.head_ref, 'capstone')) && needs.changes.outputs.edited == 'true' }}
timeout: 45
cflags: "-Wno-cpp"
allow_failure: false
- name: no-gpl-code
os: ubuntu-22.04
build_system: meson
Expand Down
2 changes: 1 addition & 1 deletion doc/PACKAGERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ version of Capstone be dynamically linked at runtime. To do this, use the
`-Duse_sys_capstone=enabled` command line option when running `meson`.

You can override the version of Capstone Rizin will use by setting
`use_capstone_version` to one of `v4`, `v5` or `next`.
`use_capstone_version` to one of `v4`, `v5`, `v6` or `next`.

There are more bundled dependencies that can be swapped out for system versions.
At the time of writing, these are:
Expand Down
69 changes: 0 additions & 69 deletions librz/arch/isa/arm/aarch64_meta_macros.h

This file was deleted.

23 changes: 18 additions & 5 deletions librz/arch/isa/arm/arm_accessors32.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* cs_insn *insn
*/

#pragma GCC diagnostic ignored "-Wenum-compare"
#pragma GCC diagnostic ignored "-Wenum-conversion"
#define CAPSTONE_AARCH64_COMPAT_HEADER
#include <capstone/capstone.h>

#define REGID(x) insn->detail->arm.operands[x].reg
Expand All @@ -27,14 +30,24 @@
#define ISMEM(x) (insn->detail->arm.operands[x].type == ARM_OP_MEM)
#define ISFPIMM(x) (insn->detail->arm.operands[x].type == ARM_OP_FP)

#define LSHIFT(x) insn->detail->arm.operands[x].mem.lshift
#define LSHIFT2(x) insn->detail->arm.operands[x].shift.value // Dangerous, returns value even if isn't LSL
#define OPCOUNT() insn->detail->arm.op_count
#define ISSHIFTED(x) (insn->detail->arm.operands[x].shift.type != ARM_SFT_INVALID && insn->detail->arm.operands[x].shift.value != 0)
#define SHIFTTYPE(x) insn->detail->arm.operands[x].shift.type
#if CS_NEXT_VERSION < 6
#define LSHIFT(x) insn->detail->arm.operands[x].mem.lshift
#else
#define LSHIFT(x) insn->detail->arm.operands[x].shift.value
#endif
#define LSHIFT2(x) insn->detail->arm.operands[x].shift.value // Dangerous, returns value even if isn't LSL
#define OPCOUNT() insn->detail->arm.op_count
#define ISSHIFTED(x) (insn->detail->arm.operands[x].shift.type != ARM_SFT_INVALID && insn->detail->arm.operands[x].shift.value != 0)
#define SHIFTTYPE(x) insn->detail->arm.operands[x].shift.type

#if CS_NEXT_VERSION < 6
#define SHIFTTYPEREG(x) (SHIFTTYPE(x) == ARM_SFT_ASR_REG || SHIFTTYPE(x) == ARM_SFT_LSL_REG || \
SHIFTTYPE(x) == ARM_SFT_LSR_REG || SHIFTTYPE(x) == ARM_SFT_ROR_REG || \
SHIFTTYPE(x) == ARM_SFT_RRX_REG)
#else
#define SHIFTTYPEREG(x) (SHIFTTYPE(x) == ARM_SFT_ASR_REG || SHIFTTYPE(x) == ARM_SFT_LSL_REG || \
SHIFTTYPE(x) == ARM_SFT_LSR_REG || SHIFTTYPE(x) == ARM_SFT_ROR_REG)
#endif
#define SHIFTVALUE(x) insn->detail->arm.operands[x].shift.value

#if CS_NEXT_VERSION >= 6
Expand Down
29 changes: 15 additions & 14 deletions librz/arch/isa/arm/arm_accessors64.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
* cs_insn *insn
*/

#define CAPSTONE_AARCH64_COMPAT_HEADER
#include <capstone/capstone.h>

#define IMM64(x) (ut64)(insn->detail->CS_aarch64_.operands[x].imm)
#define INSOP64(x) insn->detail->CS_aarch64_.operands[x]
#define IMM64(x) (ut64)(insn->detail->arm64.operands[x].imm)
#define INSOP64(x) insn->detail->arm64.operands[x]

#define REGID64(x) insn->detail->CS_aarch64_.operands[x].reg
#define REGBASE64(x) insn->detail->CS_aarch64_.operands[x].mem.base
#define REGID64(x) insn->detail->arm64.operands[x].reg
#define REGBASE64(x) insn->detail->arm64.operands[x].mem.base
// s/index/base|reg/
#define HASMEMINDEX64(x) (insn->detail->CS_aarch64_.operands[x].mem.index != CS_AARCH64(_REG_INVALID))
#define MEMDISP64(x) (ut64) insn->detail->CS_aarch64_.operands[x].mem.disp
#define ISIMM64(x) (insn->detail->CS_aarch64_.operands[x].type == CS_AARCH64(_OP_IMM))
#define ISREG64(x) (insn->detail->CS_aarch64_.operands[x].type == CS_AARCH64(_OP_REG))
#define ISMEM64(x) (insn->detail->CS_aarch64_.operands[x].type == CS_AARCH64(_OP_MEM))
#define HASMEMINDEX64(x) (insn->detail->arm64.operands[x].mem.index != ARM64_REG_INVALID)
#define MEMDISP64(x) (ut64) insn->detail->arm64.operands[x].mem.disp
#define ISIMM64(x) (insn->detail->arm64.operands[x].type == ARM64_OP_IMM)
#define ISREG64(x) (insn->detail->arm64.operands[x].type == ARM64_OP_REG)
#define ISMEM64(x) (insn->detail->arm64.operands[x].type == ARM64_OP_MEM)

#define LSHIFT2_64(x) insn->detail->CS_aarch64_.operands[x].shift.value
#define OPCOUNT64() insn->detail->CS_aarch64_.op_count
#define LSHIFT2_64(x) insn->detail->arm64.operands[x].shift.value
#define OPCOUNT64() insn->detail->arm64.op_count

#if CS_NEXT_VERSION < 6
#define ISWRITEBACK64() (insn->detail->arm64.writeback == true)
Expand All @@ -33,6 +34,6 @@
#define ISPREINDEX64() (((OPCOUNT64() == 2) && (ISMEM64(1)) && (ISWRITEBACK64())) || ((OPCOUNT64() == 3) && (ISMEM64(2)) && (ISWRITEBACK64())))
#define ISPOSTINDEX64() (((OPCOUNT64() == 3) && (ISIMM64(2)) && (ISWRITEBACK64())) || ((OPCOUNT64() == 4) && (ISIMM64(3)) && (ISWRITEBACK64())))
#else
#define ISPREINDEX64() (!insn->detail->CS_aarch64_.post_index && ISWRITEBACK64())
#define ISPOSTINDEX64() (insn->detail->CS_aarch64_.post_index && ISWRITEBACK64())
#endif
#define ISPREINDEX64() (!insn->detail->arm64.post_index && ISWRITEBACK64())
#define ISPOSTINDEX64() (insn->detail->arm64.post_index && ISWRITEBACK64())
#endif
6 changes: 4 additions & 2 deletions librz/arch/isa/arm/arm_cs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#define RZ_ARM_CS_H

#include <rz_analysis.h>
#pragma GCC diagnostic ignored "-Wenum-compare"
#pragma GCC diagnostic ignored "-Wenum-conversion"
#define CAPSTONE_AARCH64_COMPAT_HEADER
#include <capstone/capstone.h>
#include "aarch64_meta_macros.h"

RZ_IPI int rz_arm_cs_analysis_op_32_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn, bool thumb);
RZ_IPI int rz_arm_cs_analysis_op_64_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn);
Expand All @@ -19,7 +21,7 @@ RZ_IPI const char *rz_arm32_cs_esil_prefix_cond(RzAnalysisOp *op, ARMCC_CondCode
#else
RZ_IPI const char *rz_arm32_cs_esil_prefix_cond(RzAnalysisOp *op, arm_cc cond_type);
#endif
RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, CS_aarch64_cc() cond_type);
RZ_IPI const char *rz_arm64_cs_esil_prefix_cond(RzAnalysisOp *op, ARM64CC_CondCode cond_type);

RZ_IPI RzILOpEffect *rz_arm_cs_32_il(csh *handle, cs_insn *insn, bool thumb);
RZ_IPI RzAnalysisILConfig *rz_arm_cs_32_il_config(bool big_endian);
Expand Down
5 changes: 5 additions & 0 deletions librz/arch/isa/arm/arm_esil32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// SPDX-License-Identifier: LGPL-3.0-only

#include <rz_analysis.h>
#pragma GCC diagnostic ignored "-Wenum-compare"
#pragma GCC diagnostic ignored "-Wenum-conversion"
#define CAPSTONE_AARCH64_COMPAT_HEADER
#include <capstone/capstone.h>

#include "arm_cs.h"
Expand Down Expand Up @@ -34,7 +37,9 @@ static const char *decode_shift(arm_shifter shift) {
case ARM_SFT_ROR:
case ARM_SFT_RRX:
case ARM_SFT_ROR_REG:
#if CS_NEXT_VERSION < 6
case ARM_SFT_RRX_REG:
#endif
return E_OP_RR;

default:
Expand Down
Loading
Loading