Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compilation and tests
Browse files Browse the repository at this point in the history
wargio committed Sep 20, 2024
1 parent f5c33a6 commit 5aed8a8
Showing 13 changed files with 696 additions and 1,162 deletions.
30 changes: 26 additions & 4 deletions librz/arch/isa/mips/mips_esil.c
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#include <capstone/mips.h>

#define OPCOUNT() insn->detail->mips.op_count
#define REGID(x) insn->detail->mips.operands[x].reg
#define REG(x) cs_reg_name(*handle, insn->detail->mips.operands[x].reg)
#define IMM(x) insn->detail->mips.operands[x].imm

@@ -58,10 +59,18 @@ static inline void es_add_ck(RzAnalysisOp *op, const char *a1, const char *a2, c
bit - 2, mask, a1, a2, bit - 1, mask, a1, a2, a1, a2, re);
}

#if CS_NEXT_VERSION < 6
#define PROTECT_ZERO() \
if (REGID(0) == MIPS_REG_ZERO) { \
rz_strbuf_appendf(&op->esil, ","); \
} else
#else
#define PROTECT_ZERO() \
if (REG(0)[0] == 'z') { \
if (REGID(0) == MIPS_REG_ZERO || \
REGID(0) == MIPS_REG_ZERO_64) { \
rz_strbuf_appendf(&op->esil, ","); \
} else
#endif // CS_NEXT_VERSION

#define ESIL_LOAD(size) \
PROTECT_ZERO() { \
@@ -215,7 +224,16 @@ RZ_IPI int analyze_op_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8
break;
case MIPS_INS_SLLV:
case MIPS_INS_SLL:
#if CS_NEXT_VERSION < 6
rz_strbuf_appendf(&op->esil, "%s,%s,<<,%s,=", ARG(2), ARG(1), ARG(0));
#else
if (REGID(0) == MIPS_REG_INVALID) {
// NOP
rz_strbuf_setf(&op->esil, ",");
} else {
rz_strbuf_appendf(&op->esil, "%s,%s,<<,%s,=", ARG(2), ARG(1), ARG(0));
}
#endif /* CS_NEXT_VERSION */
break;
case MIPS_INS_BAL:
case MIPS_INS_JAL:
@@ -434,24 +452,28 @@ RZ_IPI int analyze_op_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8
ESIL_LOAD("1");
break;
case MIPS_INS_LBU:
case MIPS_INS_LBUX:
// one of these is wrong
ESIL_LOAD("1");
break;
case MIPS_INS_LL:
case MIPS_INS_LW:
case MIPS_INS_LWC1:
case MIPS_INS_LWC2:
case MIPS_INS_LWL:
case MIPS_INS_LWR:
case MIPS_INS_LWU:
case MIPS_INS_LL:
case MIPS_INS_LWXC1:
ESIL_LOAD("4");
break;

case MIPS_INS_LDL:
case MIPS_INS_LD:
case MIPS_INS_LDC1:
case MIPS_INS_LDC2:
case MIPS_INS_LDL:
case MIPS_INS_LDR:
case MIPS_INS_LDXC1:
case MIPS_INS_LLD:
case MIPS_INS_LD:
ESIL_LOAD("8");
break;

1 change: 0 additions & 1 deletion librz/arch/p/analysis/analysis_arm_cs.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2013-2021 pancake <pancake@nopcode.org>
// SPDX-License-Identifier: LGPL-3.0-only

#include "aarch64.h"
#include <rz_analysis.h>
#include <rz_lib.h>
#include <rz_util/ht_uu.h>
Loading

0 comments on commit 5aed8a8

Please sign in to comment.