Skip to content

Commit

Permalink
Remove CS_API_VERSION >= 4 checks since always true from now on.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Oct 20, 2023
1 parent 6d549bc commit cf170e7
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 93 deletions.
2 changes: 0 additions & 2 deletions librz/analysis/arch/x86/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const char *x86_registers[X86_REG_ENDING] = {
[X86_REG_DR5] = "dr5",
[X86_REG_DR6] = "dr6",
[X86_REG_DR7] = "dr7",
#if CS_API_MAJOR >= 4
[X86_REG_DR8] = "dr8",
[X86_REG_DR9] = "dr9",
[X86_REG_DR10] = "dr10",
Expand All @@ -90,7 +89,6 @@ const char *x86_registers[X86_REG_ENDING] = {
[X86_REG_DR13] = "dr13",
[X86_REG_DR14] = "dr14",
[X86_REG_DR15] = "dr15",
#endif
[X86_REG_FP0] = "fp0",
[X86_REG_FP1] = "fp1",
[X86_REG_FP2] = "fp2",
Expand Down
4 changes: 0 additions & 4 deletions librz/analysis/p/analysis_arm_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,8 @@ static void anop64(ArmCSContext *ctx, RzAnalysisOp *op, cs_insn *insn) {
op->family = RZ_ANALYSIS_OP_FAMILY_CRYPTO;
} else if (cs_insn_group(handle, insn, ARM64_GRP_CRC)) {
op->family = RZ_ANALYSIS_OP_FAMILY_CRYPTO;
#if CS_API_MAJOR >= 4
} else if (cs_insn_group(handle, insn, ARM64_GRP_PRIVILEGE)) {
op->family = RZ_ANALYSIS_OP_FAMILY_PRIV;
#endif
} else if (cs_insn_group(handle, insn, ARM64_GRP_NEON)) {
op->family = RZ_ANALYSIS_OP_FAMILY_MMX;
} else if (cs_insn_group(handle, insn, ARM64_GRP_FPARMV8)) {
Expand Down Expand Up @@ -1019,12 +1017,10 @@ static void anop32(RzAnalysis *a, csh handle, RzAnalysisOp *op, cs_insn *insn, b
op->family = RZ_ANALYSIS_OP_FAMILY_CRYPTO;
} else if (cs_insn_group(handle, insn, ARM_FEATURE_HasCRC)) {
op->family = RZ_ANALYSIS_OP_FAMILY_CRYPTO;
#if CS_API_MAJOR >= 4
} else if (cs_insn_group(handle, insn, ARM_GRP_PRIVILEGE)) {
op->family = RZ_ANALYSIS_OP_FAMILY_PRIV;
} else if (cs_insn_group(handle, insn, ARM_FEATURE_HasVirtualization)) {
op->family = RZ_ANALYSIS_OP_FAMILY_VIRT;
#endif
} else if (cs_insn_group(handle, insn, ARM_FEATURE_HasNEON)) {
op->family = RZ_ANALYSIS_OP_FAMILY_MMX;
} else if (cs_insn_group(handle, insn, ARM_FEATURE_HasFPARMv8)) {
Expand Down
24 changes: 0 additions & 24 deletions librz/analysis/p/analysis_m680x_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
#include <rz_lib.h>
#include <capstone/capstone.h>

#if CS_API_MAJOR >= 4 && CS_API_MINOR >= 0
#define CAPSTONE_HAS_M680X 1
#else
#define CAPSTONE_HAS_M680X 0
#endif

#if !CAPSTONE_HAS_M680X
#ifdef _MSC_VER
#pragma message("Cannot find support for m680x in capstone")
#else
#warning Cannot find capstone-m680x support
#endif
#endif

#if CAPSTONE_HAS_M680X
#include <capstone/m680x.h>

static int m680xmode(const char *str) {
Expand Down Expand Up @@ -538,15 +523,6 @@ RzAnalysisPlugin rz_analysis_plugin_m680x_cs = {
.bits = 16 | 32,
.op = &analyze_op,
};
#else
RzAnalysisPlugin rz_analysis_plugin_m680x_cs = {
.name = "m680x (unsupported)",
.desc = "Capstone M680X analyzer (unsupported)",
.license = "BSD",
.arch = "m680x",
.bits = 32,
};
#endif

#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct rizin_plugin = {
Expand Down
7 changes: 0 additions & 7 deletions librz/analysis/p/analysis_m68k_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,12 @@ static inline ut64 make_64bits_address(ut64 address) {
}

static inline void handle_branch_instruction(RzAnalysisOp *op, ut64 addr, cs_m68k *m68k, ut32 type, int index) {
#if CS_API_MAJOR >= 4
if (m68k->operands[index].type == M68K_OP_BR_DISP) {
op->type = type;
// TODO: disp_size is ignored
op->jump = make_64bits_address(addr + m68k->operands[index].br_disp.disp + 2);
op->fail = make_64bits_address(addr + op->size);
}
#else
op->type = type;
// TODO: disp_size is ignored
op->jump = make_64bits_address(addr + m68k->operands[index].br_disp.disp + 2);
op->fail = make_64bits_address(addr + op->size);
#endif
}

static inline void handle_jump_instruction(RzAnalysisOp *op, ut64 addr, cs_m68k *m68k, ut32 type) {
Expand Down
8 changes: 0 additions & 8 deletions librz/analysis/p/analysis_ppc_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,7 @@ static int analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
op->size = insn->size;
op->id = insn->id;
switch (insn->id) {
#if CS_API_MAJOR >= 4
case PPC_INS_CMPB:
#endif
case PPC_INS_CMPD:
case PPC_INS_CMPDI:
case PPC_INS_CMPLD:
Expand Down Expand Up @@ -1137,9 +1135,7 @@ static int analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
esilprintf(op, "%s,%s,=[8],%s=", ARG(0), op1, op1);
break;
case PPC_INS_LBZ:
#if CS_API_MAJOR >= 4
case PPC_INS_LBZCIX:
#endif
case PPC_INS_LBZU:
case PPC_INS_LBZUX:
op->type = RZ_ANALYSIS_OP_TYPE_LOAD;
Expand All @@ -1155,9 +1151,7 @@ static int analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
break;
case PPC_INS_LD:
case PPC_INS_LDARX:
#if CS_API_MAJOR >= 4
case PPC_INS_LDCIX:
#endif
case PPC_INS_LDU:
case PPC_INS_LDUX:
op->type = RZ_ANALYSIS_OP_TYPE_LOAD;
Expand Down Expand Up @@ -1208,9 +1202,7 @@ static int analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
case PPC_INS_LWAUX:
case PPC_INS_LWAX:
case PPC_INS_LWZ:
#if CS_API_MAJOR >= 4
case PPC_INS_LWZCIX:
#endif
case PPC_INS_LWZX:
op->type = RZ_ANALYSIS_OP_TYPE_LOAD;
esilprintf(op, "%s,%s,=", ARG2(1, "[4]"), ARG(0));
Expand Down
26 changes: 0 additions & 26 deletions librz/analysis/p/analysis_x86_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ static void hidden_op(cs_insn *insn, cs_x86 *x, int mode) {
op->type = X86_OP_REG;
op->reg = X86_REG_EFLAGS;
op->size = regsz;
#if CS_API_MAJOR >= 4
if (id == X86_INS_PUSHF || id == X86_INS_PUSHFD || id == X86_INS_PUSHFQ) {
op->access = 1;
} else {
op->access = 2;
}
#endif
break;
case X86_INS_PUSHAW:
case X86_INS_PUSHAL:
Expand Down Expand Up @@ -122,9 +120,7 @@ static void opex(RzStrBuf *buf, X86CSContext *ctx, int mode) {
cs_x86_op *op = x->operands + i;
pj_o(pj);
pj_ki(pj, "size", op->size);
#if CS_API_MAJOR >= 4
pj_ki(pj, "rw", op->access); // read, write, read|write
#endif
switch (op->type) {
case X86_OP_REG:
pj_ks(pj, "type", "reg");
Expand Down Expand Up @@ -431,9 +427,7 @@ static void anop_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
case X86_INS_FPREM:
case X86_INS_FPREM1:
case X86_INS_FPTAN:
#if CS_API_MAJOR >= 4
case X86_INS_FFREEP:
#endif
case X86_INS_FRNDINT:
case X86_INS_FRSTOR:
case X86_INS_FNSAVE:
Expand Down Expand Up @@ -514,9 +508,7 @@ static void anop_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf
case X86_INS_CLAC:
case X86_INS_CLGI:
case X86_INS_CLTS:
#if CS_API_MAJOR >= 4
case X86_INS_CLWB:
#endif
case X86_INS_STAC:
case X86_INS_STGI:
break;
Expand Down Expand Up @@ -1905,7 +1897,6 @@ static void set_access_info(RzReg *reg, RzAnalysisOp *op, csh *handle, cs_insn *
val->reg = cs_reg2reg(reg, handle, ip);
rz_list_append(ret, val);

#if CS_API_MAJOR >= 4
// Register access info
cs_regs regs_read, regs_write;
ut8 read_count, write_count;
Expand All @@ -1929,7 +1920,6 @@ static void set_access_info(RzReg *reg, RzAnalysisOp *op, csh *handle, cs_insn *
}
}
}
#endif

switch (insn->id) {
case X86_INS_PUSH:
Expand Down Expand Up @@ -2007,7 +1997,6 @@ static void set_access_info(RzReg *reg, RzAnalysisOp *op, csh *handle, cs_insn *
if (INSOP(i).type == X86_OP_MEM) {
val = rz_analysis_value_new();
val->type = RZ_ANALYSIS_VAL_MEM;
#if CS_API_MAJOR >= 4
switch (INSOP(i).access) {
case CS_AC_READ:
val->access = RZ_ANALYSIS_ACC_R;
Expand All @@ -2019,9 +2008,6 @@ static void set_access_info(RzReg *reg, RzAnalysisOp *op, csh *handle, cs_insn *
val->access = RZ_ANALYSIS_ACC_UNKNOWN;
break;
}
#else
val->access = RZ_ANALYSIS_ACC_UNKNOWN;
#endif
val->mul = INSOP(i).mem.scale;
val->delta = INSOP(i).mem.disp;
if (INSOP(0).mem.base == X86_REG_RIP ||
Expand Down Expand Up @@ -2255,9 +2241,7 @@ static void anop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int
case X86_INS_FPREM:
case X86_INS_FPREM1:
case X86_INS_FPTAN:
#if CS_API_MAJOR >= 4
case X86_INS_FFREEP:
#endif
case X86_INS_FRNDINT:
case X86_INS_FRSTOR:
case X86_INS_FNSAVE:
Expand Down Expand Up @@ -2352,9 +2336,7 @@ static void anop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int
case X86_INS_CLAC:
case X86_INS_CLGI:
case X86_INS_CLTS:
#if CS_API_MAJOR >= 4
case X86_INS_CLWB:
#endif
case X86_INS_STAC:
case X86_INS_STGI:
op->type = RZ_ANALYSIS_OP_TYPE_MOV;
Expand Down Expand Up @@ -2466,9 +2448,7 @@ static void anop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int
case X86_INS_PCMPGTQ:
case X86_INS_PCMPISTRI:
case X86_INS_PCMPISTRM:
#if CS_API_MAJOR >= 4
case X86_INS_VPCMPB:
#endif
case X86_INS_VPCMPD:
case X86_INS_VPCMPEQB:
case X86_INS_VPCMPEQD:
Expand All @@ -2483,15 +2463,11 @@ static void anop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int
case X86_INS_VPCMPISTRI:
case X86_INS_VPCMPISTRM:
case X86_INS_VPCMPQ:
#if CS_API_MAJOR >= 4
case X86_INS_VPCMPUB:
#endif
case X86_INS_VPCMPUD:
case X86_INS_VPCMPUQ:
#if CS_API_MAJOR >= 4
case X86_INS_VPCMPUW:
case X86_INS_VPCMPW:
#endif
op->type = RZ_ANALYSIS_OP_TYPE_CMP;
op->family = RZ_ANALYSIS_OP_FAMILY_SSE;
break;
Expand Down Expand Up @@ -2727,9 +2703,7 @@ static void anop(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int
op->stackptr = -regsz;
op->cycles = CYCLE_MEM + CYCLE_JMP;
break;
#if CS_API_MAJOR >= 4
case X86_INS_UD0:
#endif
case X86_INS_UD2:
#if CS_API_MAJOR == 4
case X86_INS_UD2B:
Expand Down
18 changes: 0 additions & 18 deletions librz/asm/p/asm_m680x_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
#include <rz_lib.h>
#include <capstone/capstone.h>

#if CS_API_MAJOR >= 4 && CS_API_MINOR >= 0
#define CAPSTONE_HAS_M680X 1
#else
#define CAPSTONE_HAS_M680X 0
#endif

#if CAPSTONE_HAS_M680X

static csh cd = 0;

static int m680xmode(const char *str) {
Expand Down Expand Up @@ -104,16 +96,6 @@ RzAsmPlugin rz_asm_plugin_m680x_cs = {
.disassemble = &disassemble,
};

#else
RzAsmPlugin rz_asm_plugin_m680x_cs = {
.name = "m680x",
.desc = "Capstone M680X Disassembler (Not supported)",
.license = "BSD",
.arch = "m680x",
.bits = 8 | 32,
};
#endif

#ifndef RZ_PLUGIN_INCORE
RZ_API RzLibStruct rizin_plugin = {
.type = RZ_LIB_TYPE_ASM,
Expand Down
4 changes: 0 additions & 4 deletions librz/asm/p/asm_x86_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
}
// always unsigned immediates (kernel addresses)
// maybe rizin should have an option for this too?
#if CS_API_MAJOR >= 4
cs_option(cd, CS_OPT_UNSIGNED, CS_OPT_ON);
#endif
if (a->syntax == RZ_ASM_SYNTAX_MASM) {
#if CS_API_MAJOR >= 4
cs_option(cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_MASM);
#endif
} else if (a->syntax == RZ_ASM_SYNTAX_ATT) {
cs_option(cd, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT);
} else {
Expand Down

0 comments on commit cf170e7

Please sign in to comment.