11 #define REG_BUF_MAX 32
15 #define ES_IS_NEGATIVE(arg) "1," arg ",<<<,1,&"
17 #define ES_B(x) "0xff," x ",&"
18 #define ES_H(x) "0xffff," x ",&"
19 #define ES_W(x) "0xffffffff," x ",&"
21 #define ES_CALL_DR(ra, addr) "pc,4,+," ra ",=," ES_J(addr)
22 #define ES_CALL_D(addr) ES_CALL_DR("ra", addr)
25 #define ES_CALL_NDR(ra, addr) "pc," ra ",=," ES_J(addr)
26 #define ES_CALL_ND(addr) ES_CALL_NDR("ra", addr)
31 #define ES_TRAP_DS() "$ds,!,!,?{,$$,1,TRAP,BREAK,},"
33 #define ES_J(addr) addr ",SETJT,1,SETD"
35 #define ES_TRAP_DS() ""
36 #define ES_J(addr) addr ",pc,="
39 #define ES_SIGN32_64(arg) es_sign_n_64(a, op, arg, 32)
40 #define ES_SIGN16_64(arg) es_sign_n_64(a, op, arg, 16)
42 #define ES_ADD_CK32_OVERF(x, y, z) es_add_ck(op, x, y, z, 32)
43 #define ES_ADD_CK64_OVERF(x, y, z) es_add_ck(op, x, y, z, 64)
47 rz_strbuf_appendf(&
op->esil,
",%d,%s,~,%s,=,",
bit,
arg,
arg);
56 "%d,0x%" PFMT64x ",%s,%s,^,&,>>,%d,0x%" PFMT64x ",%s,%s,+,&,>>,|,1,==,$z,?{,$$,1,TRAP,}{,%s,%s,+,%s,=,}",
57 bit - 2,
mask, a1, a2,
bit - 1,
mask, a1, a2, a1, a2, re);
726 #define R_REG(x) ((const char *)insn->r_reg.x)
727 #define I_REG(x) ((const char *)insn->i_reg.x)
728 #define J_REG(x) ((const char *)insn->j_reg.x)
733 static const char *REGISTERS[32] = {
734 "zero",
"at",
"v0",
"v1",
"a0",
"a1",
"a2",
"a3",
735 "t0",
"t1",
"t2",
"t3",
"t4",
"t5",
"t6",
"t7",
736 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
737 "t8",
"t9",
"k0",
"k1",
"gp",
"sp",
"fp",
"ra"
740 return REGISTERS[reg_num];
788 ES_W(
"%s,%s")
",>>,31,%s,>>,?{,%s,32,-,0xffffffff,<<,0xffffffff,&,}{,0,},|,%s,=",
793 "%s,%s,>>,31,%s,>>,?{,32,%s,32,-,0xffffffff,<<,0xffffffff,&,<<,}{,0,},|,%s,=",
815 if (strcmp(
R_REG(
rd),
"rd") == 0) {
855 rz_strbuf_appendf(&
op->esil,
ES_TRAP_DS()
"0,%s,==,$z,?{," ES_J(
"%s")
",BREAK,},",
897 rz_strbuf_appendf(&
op->esil,
"0,%s,==,$z,?{,%s,%s,=,}",
901 rz_strbuf_appendf(&
op->esil,
"1,%s,==,$z,?{,%s,%s,=,}",
1001 rz_strbuf_appendf(&
op->esil,
"%s,%s,|,0xffffffff,^,%s,=",
R_REG(
rs),
R_REG(rt),
R_REG(
rd));
1010 rz_strbuf_appendf(&
op->esil,
"%s,0xffffffff,&,%s,0xffffffff,&,<,t,=",
1014 rz_strbuf_appendf(&
op->esil,
"%s,0xffffffff,&,%s,0xffffffff,&,<,%s,=",
1052 int optype, oplen = (analysis->
bits == 16) ? 2 : 4;
1097 int rs = ((
buf[0] & 3) << 3) + (
buf[1] >> 5);
1098 int rt =
buf[1] & 31;
1099 int rd =
buf[2] >> 3;
1100 int sa = ((
buf[2] & 7) << 2) + (
buf[3] >> 6);
1101 int fun =
buf[3] & 63;
1150 }
else if (
rs == 25) {
1263 }
else if ((
optype & 0x3e) == 2) {
1290 int address = (((
buf[0] & 3) << 24) + (
buf[1] << 16) + (
buf[2] << 8) +
buf[3]) << 2;
1291 ut64 page_hack =
addr & 0xf0000000;
1297 op->jump = page_hack + address;
1304 op->jump = page_hack + address;
1311 }
else if ((
optype & 0x3c) == 0x10) {
1326 int fmt = ((
buf[0] & 3) << 3) + (
buf[1] >> 5);
1327 int ft = (
buf[1] & 31);
1328 int fs = (
buf[2] >> 3);
1329 int fd = (
buf[2] & 7) + (
buf[3] >> 6);
1331 int fun = (
buf[3] & 63);
1360 int rs = ((
buf[0] & 3) << 3) + (
buf[1] >> 5);
1361 int rt =
buf[1] & 31;
1363 if (((
optype >> 2) ^ 0x3) && (
imm & 0x8000)) {
1364 imm = 0 - (0x10000 -
imm);
1687 "gpr zero .32 0 0\n"
1712 "gpr t9 .32 100 0\n"
1713 "gpr k0 .32 104 0\n"
1714 "gpr k1 .32 108 0\n"
1715 "gpr gp .32 112 0\n"
1716 "gpr sp .32 116 0\n"
1717 "gpr fp .32 120 0\n"
1718 "gpr ra .32 124 0\n"
1719 "gpr pc .32 128 0\n";
1729 "gpr zero .64 0 0\n"
1745 "gpr t5 .64 104 0\n"
1746 "gpr t6 .64 112 0\n"
1747 "gpr t7 .64 120 0\n"
1749 "gpr s0 .64 128 0\n"
1750 "gpr s1 .64 136 0\n"
1751 "gpr s2 .64 144 0\n"
1752 "gpr s3 .64 152 0\n"
1753 "gpr s4 .64 160 0\n"
1754 "gpr s5 .64 168 0\n"
1755 "gpr s6 .64 176 0\n"
1756 "gpr s7 .64 184 0\n"
1757 "gpr t8 .64 192 0\n"
1758 "gpr t9 .64 200 0\n"
1760 "gpr k0 .64 208 0\n"
1761 "gpr k1 .64 216 0\n"
1762 "gpr gp .64 224 0\n"
1763 "gpr sp .64 232 0\n"
1764 "gpr fp .64 240 0\n"
1765 "gpr ra .64 248 0\n"
1767 "gpr pc .64 272 0\n";
1778 .desc =
"MIPS code analysis plugin",
1788 #ifndef RZ_PLUGIN_INCORE
RZ_API RzAnalysisValue * rz_analysis_value_new(void)
static const char * mips_reg_decode(ut32 reg_num)
static char * mips_get_reg_profile(RzAnalysis *analysis)
static int analop_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, gnu_insn *insn)
#define ES_CALL_DR(ra, addr)
#define ES_ADD_CK32_OVERF(x, y, z)
#define ES_ADD_CK64_OVERF(x, y, z)
static void es_sign_n_64(RzAnalysis *a, RzAnalysisOp *op, const char *arg, int bit)
RZ_API RzLibStruct rizin_plugin
#define ES_SIGN32_64(arg)
static int mips_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b, int len, RzAnalysisOpMask mask)
#define ES_IS_NEGATIVE(arg)
static void es_add_ck(RzAnalysisOp *op, const char *a1, const char *a2, const char *re, int bit)
RzAnalysisPlugin rz_analysis_plugin_mips_gnu
static int archinfo(RzAnalysis *analysis, int q)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
@ RZ_ANALYSIS_OP_MASK_VAL
@ RZ_ANALYSIS_OP_MASK_ESIL
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_UNK
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_NOR
@ RZ_ANALYSIS_OP_TYPE_SWI
@ RZ_ANALYSIS_OP_TYPE_SAR
@ RZ_ANALYSIS_OP_TYPE_TRAP
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_RJMP
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_DIV
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_UCALL
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_NOP
@ RZ_ANALYSIS_OP_TYPE_RCALL
@ RZ_ANALYSIS_OP_TYPE_XOR
static ut32 rz_read_ble32(const void *src, bool big_endian)
static ut32 rz_swap_ut32(ut32 val)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API void rz_strbuf_fini(RzStrBuf *sb)
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]