Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bd0d9a6
sys: bump capstone to 6.0.0-alpha4, fix arm64 and sysz rename
jiegec May 23, 2025
e794cd0
rs: rename arm64 -> aarch64 and sysz -> systemz to follow upstream
jiegec May 23, 2025
e8d28fa
rs: adapt to capstone v6 changes, mainly in aarch64
jiegec May 23, 2025
82776cf
rs: use aarch64_reg::Type for windows compat
jiegec May 23, 2025
b5ba6cd
rs: run cargo fmt to make ci happy
jiegec May 23, 2025
f819683
rs, sys: mention capstone 6.0.0-alpha4 and arch renaming in CHANGELOG
jiegec May 23, 2025
81b8f84
rs: avoid possible panics in library functions
jiegec May 23, 2025
c046d65
rs: add missing doc comments
jiegec May 23, 2025
cf181eb
rs, sys: generate arm_spsr_cspr_bits as bitfield enum
jiegec May 24, 2025
dbaa68d
rs: add previously failed testcase from issue 175
jiegec May 24, 2025
2434a33
ci: rename arch_arm64 to arch_aarch64 feature
jiegec May 24, 2025
fe0037b
sys: add Alpha arch support
jiegec May 24, 2025
30395c2
rs, sys: fix feature detection after renaming
jiegec May 24, 2025
4b82151
sys: add HPPA arch support
jiegec May 24, 2025
9262f5e
sys: add LoongArch arch support
jiegec May 24, 2025
0f406b2
sys: add Xtensa arch support
jiegec May 24, 2025
5de6e80
sys: add ARC arch support
jiegec May 24, 2025
4f00085
sys: move bpf bindings around to become in order
jiegec May 24, 2025
47ec2a7
rs: add Alpha arch support
jiegec May 24, 2025
2a17cf9
sys: fix build.rs lifetime for Rust 1.70.0
jiegec May 24, 2025
240bf5d
rs: add HPPA arch support
jiegec May 24, 2025
f16b5fd
rs: add LoongArch arch support
jiegec May 24, 2025
fd27c2c
rs: rename variable to reflect its type
jiegec May 24, 2025
82bf2e2
rs: disable failing hppa test due to upstream bug
jiegec May 24, 2025
bf6ed1f
rs: add Xtensa arch support
jiegec May 24, 2025
73c58d8
rs: fix tests on windows
jiegec May 24, 2025
65d5bdd
rs: add ARC arch support
jiegec May 24, 2025
f541a20
rs: fix type conversion on windows
jiegec May 24, 2025
265669b
rs: bump capstone to 6.0.0-Alpha4-8-gefc0ba44 to fix upstream bugs
jiegec May 26, 2025
b042b2a
rs: update tests after upstream bugs are fixed
jiegec May 26, 2025
804f160
rs: test CS_OPT_UNSIGNED using x86 code
jiegec May 26, 2025
9905c32
rs, sys: bump capstone to 6.0.0-Alpha4-13-gfe6bdc6e
jiegec Jun 15, 2025
202cf86
sys: bump capstone to 6.0.0-Alpha4-25-g717d8b05
jiegec Jul 9, 2025
f8f2520
rs: bump capstone to 6.0.0-Alpha4-25-g717d8b05
jiegec Jul 9, 2025
4b199bb
rs: add access mode to sparc operand
jiegec Jul 9, 2025
d878ee3
rs: document recent changes in CHANGELOG
jiegec Jul 9, 2025
05aea5d
rs: update tests for sparc, not a bug actually
jiegec Jul 9, 2025
6c99b35
rs: apply cargo clippy
jiegec Jul 9, 2025
0f57559
rs: fix tests on windows
jiegec Jul 9, 2025
36a2b30
rs, sys: bump capstone to 6.0.0-Alpha5
jiegec Aug 4, 2025
071ee66
rs: zero initialize cs_insn to make valgrind happy
jiegec Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
rs, sys: bump capstone to 6.0.0-Alpha4-13-gfe6bdc6e
  • Loading branch information
jiegec committed Aug 4, 2025
commit 9905c3200491871def0e55adf655b93e147173ca
4 changes: 2 additions & 2 deletions capstone-rs/src/arch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::arch::DetailsArchInsn;
use crate::instruction::{AccessType, RegId, RegIdInt};
use capstone_sys::{
aarch64_imm_range, aarch64_op_mem, aarch64_op_pred, aarch64_op_sme, aarch64_op_type,
aarch64_sme_op_type, aarch64_sysop, cs_aarch64, cs_aarch64_op, cs_ac_type,
aarch64_sme_op_type, aarch64_sysop, cs_aarch64, cs_aarch64_op,
};
use core::convert::{From, TryInto};
use core::{cmp, fmt, slice};
Expand Down Expand Up @@ -474,7 +474,7 @@ impl From<&cs_aarch64_op> for AArch64Operand {
None
};
AArch64Operand {
access: cs_ac_type(op.access as _).try_into().ok(),
access: op.access.try_into().ok(),
vector_index,
vas: op.vas,
shift,
Expand Down
6 changes: 3 additions & 3 deletions capstone-rs/src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::convert::{From, TryInto};
use core::{cmp, fmt, slice};

use capstone_sys::{
arm_op_mem, arm_op_type, arm_shifter, cs_ac_type, cs_arm, cs_arm_op, cs_arm_op__bindgen_ty_2,
arm_op_mem, arm_op_type, arm_shifter, cs_arm, cs_arm_op, cs_arm_op__bindgen_ty_2,
};
use libc::c_uint;

Expand Down Expand Up @@ -306,7 +306,7 @@ impl From<&cs_arm_op> for ArmOperand {
shift,
op_type,
subtracted: op.subtracted,
access: cs_ac_type(op.access as _).try_into().ok(),
access: op.access.try_into().ok(),
}
}
}
Expand Down Expand Up @@ -388,7 +388,7 @@ mod test {
type_: arm_op_type::ARM_OP_INVALID,
__bindgen_anon_1: cs_arm_op__bindgen_ty_2 { imm: 0 },
subtracted: false,
access: 0,
access: cs_ac_type(0),
neon_lane: 0,
}; 36],
vcc: VPTCodes::ARMVCC_None,
Expand Down
4 changes: 2 additions & 2 deletions capstone-rs/src/arch/loongarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::{cmp, fmt, slice};
pub use capstone_sys::loongarch_insn as LoongArchInsn;
pub use capstone_sys::loongarch_reg as LoongArchReg;
use capstone_sys::{
cs_ac_type, cs_loongarch, cs_loongarch_op, cs_loongarch_op__bindgen_ty_1, loongarch_op_mem,
cs_loongarch, cs_loongarch_op, cs_loongarch_op__bindgen_ty_1, loongarch_op_mem,
loongarch_op_type,
};

Expand Down Expand Up @@ -39,7 +39,7 @@ impl From<&cs_loongarch_op> for LoongArchOperand {
let op_type = LoongArchOperandType::new(op.type_, op.__bindgen_anon_1);
LoongArchOperand {
op_type,
access: cs_ac_type(op.access as _).try_into().ok(),
access: op.access.try_into().ok(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion capstone-rs/src/arch/m680x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ mod test {
type_: m680x_op_type::M680X_OP_INVALID,
__bindgen_anon_1: cs_m680x_op__bindgen_ty_1 { reg: 0 },
size: 1,
access: 0,
access: cs_ac_type(0),
};

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion capstone-rs/src/arch/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod test {
__bindgen_anon_1: cs_mips_op__bindgen_ty_1 { reg: 0 },
is_reglist: false,
is_unsigned: false,
access: 0,
access: cs_ac_type(0),
};
assert_eq!(MipsOperand::from(&op), MipsOperand::Invalid);
}
Expand Down
6 changes: 3 additions & 3 deletions capstone-rs/src/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use capstone_sys::x86_reg as X86Reg;
pub use capstone_sys::x86_sse_cc as X86SseCC;
pub use capstone_sys::x86_xop_cc as X86XopCC;
use capstone_sys::{
cs_ac_type, cs_x86, cs_x86_op, cs_x86_op__bindgen_ty_1, x86_op_mem, x86_op_type,
cs_x86, cs_x86_op, cs_x86_op__bindgen_ty_1, x86_op_mem, x86_op_type,
};

use super::InsnOffsetSpan;
Expand Down Expand Up @@ -233,7 +233,7 @@ impl From<&cs_x86_op> for X86Operand {
let op_type = X86OperandType::new(op.type_, op.__bindgen_anon_1);
X86Operand {
size: op.size,
access: cs_ac_type(op.access as _).try_into().ok(),
access: op.access.try_into().ok(),
avx_bcast: op.avx_bcast,
avx_zero_opmask: op.avx_zero_opmask,
op_type,
Expand Down Expand Up @@ -369,7 +369,7 @@ mod test {
size: 0,
avx_bcast: x86_avx_bcast::X86_AVX_BCAST_INVALID,
avx_zero_opmask: false,
access: 0,
access: cs_ac_type(0),
}; 8],
};
let mut a2 = a1;
Expand Down
18 changes: 4 additions & 14 deletions capstone-rs/src/arch/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use core::{cmp, fmt, slice};
pub use capstone_sys::xtensa_insn as XtensaInsn;
pub use capstone_sys::xtensa_reg as XtensaReg;
use capstone_sys::{
cs_ac_type, cs_xtensa, cs_xtensa_op, cs_xtensa_op_mem, cs_xtensa_op_type,
cs_xtensa_operand__bindgen_ty_1,
cs_xtensa, cs_xtensa_op, cs_xtensa_op_mem, cs_xtensa_op_type,
cs_xtensa_op__bindgen_ty_1,
};

pub use crate::arch::arch_builder::xtensa::*;
Expand Down Expand Up @@ -39,7 +39,7 @@ impl From<&cs_xtensa_op> for XtensaOperand {
let op_type = XtensaOperandType::new(op.type_, op.__bindgen_anon_1);
XtensaOperand {
op_type,
access: cs_ac_type(op.access as _).try_into().ok(),
access: op.access.try_into().ok(),
}
}
}
Expand All @@ -56,12 +56,6 @@ pub enum XtensaOperandType {
/// Memory
Mem(XtensaOpMem),

/// Memory register
MemReg(RegId),

/// Memory immediate
MemImm(i32),

/// L32R target
L32R(i32),

Expand All @@ -70,7 +64,7 @@ pub enum XtensaOperandType {
}

impl XtensaOperandType {
fn new(op_type: u8, value: cs_xtensa_operand__bindgen_ty_1) -> XtensaOperandType {
fn new(op_type: cs_xtensa_op_type::Type, value: cs_xtensa_op__bindgen_ty_1) -> XtensaOperandType {
match op_type as cs_xtensa_op_type::Type {
cs_xtensa_op_type::XTENSA_OP_REG => {
XtensaOperandType::Reg(RegId(unsafe { value.reg } as RegIdInt))
Expand All @@ -79,10 +73,6 @@ impl XtensaOperandType {
cs_xtensa_op_type::XTENSA_OP_MEM => {
XtensaOperandType::Mem(XtensaOpMem(unsafe { value.mem }))
}
cs_xtensa_op_type::XTENSA_OP_MEM_REG => {
XtensaOperandType::MemReg(RegId(unsafe { value.reg } as RegIdInt))
}
cs_xtensa_op_type::XTENSA_OP_MEM_IMM => XtensaOperandType::MemImm(unsafe { value.imm }),
cs_xtensa_op_type::XTENSA_OP_L32R => XtensaOperandType::L32R(unsafe { value.imm }),
_ => XtensaOperandType::Invalid,
}
Expand Down
2 changes: 1 addition & 1 deletion capstone-sys/capstone/.clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
# SPDX-License-Identifier: BSD-3-Clause
#
# clang-format configuration file. Intended for clang-format >= 11.
#
Expand Down
1 change: 0 additions & 1 deletion capstone-sys/capstone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ if(CAPSTONE_AARCH64_SUPPORT)
arch/AArch64/AArch64GenDisassemblerTables.inc
arch/AArch64/AArch64GenInstrInfo.inc
arch/AArch64/AArch64GenRegisterInfo.inc
arch/AArch64/AArch64GenRegisterName.inc
arch/AArch64/AArch64GenSubtargetInfo.inc
arch/AArch64/AArch64GenSystemOperands.inc
arch/AArch64/AArch64GenCSMappingInsn.inc
Expand Down
10 changes: 10 additions & 0 deletions capstone-sys/capstone/MCInst.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,13 @@ void MCInst_updateWithTmpMI(MCInst *MI, MCInst *TmpMI) {
assert(MI->size < MAX_MC_OPS);
memcpy(MI->Operands, TmpMI->Operands, sizeof(MI->Operands[0]) * MI->size);
}

/// @brief Sets the softfail/illegal flag in the cs_insn.
/// Setting it indicates the instruction can be decoded, but is invalid
/// due to not allowed operands or an illegal context.
///
/// @param MI The MCInst holding the cs_insn currently decoded.
void MCInst_setSoftFail(MCInst *MI) {
assert(MI && MI->flat_insn);
MI->flat_insn->illegal = true;
}
2 changes: 2 additions & 0 deletions capstone-sys/capstone/MCInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ static inline bool MCInst_isAlias(const MCInst *MI) {

void MCInst_updateWithTmpMI(MCInst *MI, MCInst *TmpMI);

void MCInst_setSoftFail(MCInst *MI);

#endif
57 changes: 57 additions & 0 deletions capstone-sys/capstone/SStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ void SStream_Init(SStream *ss)
ss->is_closed = false;
ss->markup_stream = false;
ss->prefixed_by_markup = false;
ss->unsigned_num = false;
}

void SStream_opt_unum(SStream *ss, bool print_unsigned_numbers)
{
assert(ss);
ss->unsigned_num = print_unsigned_numbers;
}

/// Returns the a pointer to the internal string buffer of the stream.
Expand Down Expand Up @@ -224,6 +231,10 @@ void SStream_concat(SStream *ss, const char *fmt, ...)
void printInt64Bang(SStream *ss, int64_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt64Bang(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
SStream_concat1(ss, '#');
printInt64(ss, val);
Expand All @@ -241,6 +252,10 @@ void printUInt64Bang(SStream *ss, uint64_t val)
void printInt64(SStream *ss, int64_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt64(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
if (val > HEX_THRESHOLD)
Expand Down Expand Up @@ -286,14 +301,40 @@ void printInt32BangDec(SStream *ss, int32_t val)
void printInt32Bang(SStream *ss, int32_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt32Bang(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
SStream_concat1(ss, '#');
printInt32(ss, val);
}

void printUInt8(SStream *ss, uint8_t val)
{
assert(ss);
if (val > HEX_THRESHOLD)
SStream_concat(ss, "0x%"PRIx8, val);
else
SStream_concat(ss, "%"PRIu8, val);
}

void printUInt16(SStream *ss, uint16_t val)
{
assert(ss);
if (val > HEX_THRESHOLD)
SStream_concat(ss, "0x%"PRIx16, val);
else
SStream_concat(ss, "%"PRIu16, val);
}

void printInt8(SStream *ss, int8_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt8(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
if (val > HEX_THRESHOLD)
Expand All @@ -314,6 +355,10 @@ void printInt8(SStream *ss, int8_t val)
void printInt16(SStream *ss, int16_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt16(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
if (val > HEX_THRESHOLD)
Expand All @@ -334,6 +379,10 @@ void printInt16(SStream *ss, int16_t val)
void printInt16HexOffset(SStream *ss, int16_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt16(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
SStream_concat(ss, "+0x%" PRIx16, val);
Expand All @@ -350,6 +399,10 @@ void printInt16HexOffset(SStream *ss, int16_t val)
void printInt32(SStream *ss, int32_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt32(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
if (val > HEX_THRESHOLD)
Expand All @@ -371,6 +424,10 @@ void printInt32(SStream *ss, int32_t val)
void printInt32HexOffset(SStream *ss, int32_t val)
{
assert(ss);
if (ss->unsigned_num) {
printUInt32(ss, val);
return;
}
SSTREAM_RETURN_IF_CLOSED(ss);
if (val >= 0) {
SStream_concat(ss, "+0x%" PRIx32, val);
Expand Down
4 changes: 4 additions & 0 deletions capstone-sys/capstone/SStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef struct SStream {
bool is_closed;
bool markup_stream; ///< If true, markups to the stream are allowed.
bool prefixed_by_markup; ///< Set after the stream wrote a markup for an operand.
bool unsigned_num; ///< Print all numbers as unsigned. Set with CS_OPT_UNSIGNED.
} SStream;

#define SSTREAM_OVERFLOW_CHECK(OS, len) \
Expand All @@ -39,6 +40,7 @@ do { \
} while(0)

void SStream_Init(SStream *ss);
void SStream_opt_unum(SStream *ss, bool print_unsigned_numbers);

const char *SStream_replc(const SStream *ss, char elem, char repl);

Expand Down Expand Up @@ -81,6 +83,8 @@ void printInt32HexOffset(SStream *ss, int32_t val);

void printUInt32Bang(SStream *O, uint32_t val);

void printUInt8(SStream *ss, uint8_t val);
void printUInt16(SStream *ss, uint16_t val);
void printUInt32(SStream *O, uint32_t val);

// print number in decimal mode
Expand Down
Loading