10 #define ARC_REG_ILINK1 0x1d
11 #define ARC_REG_ILINK2 0x1e
12 #define ARC_REG_BLINK 0x1f
13 #define ARC_REG_LIMM 0x3e
14 #define ARC_REG_PCL 0x3f
43 int maxsint = (1 << (
bits - 1)) - 1;
44 int maxuint = (1 << (
bits)) - 1;
53 #define SIGN_EXT_S7(imm) sign_ext(7, imm);
54 #define SIGN_EXT_S8(imm) sign_ext(8, imm);
55 #define SIGN_EXT_S9(imm) sign_ext(9, imm);
56 #define SIGN_EXT_S10(imm) sign_ext(10, imm);
57 #define SIGN_EXT_S12(imm) sign_ext(12, imm);
58 #define SIGN_EXT_S13(imm) sign_ext(13, imm);
59 #define SIGN_EXT_S21(imm) sign_ext(21, imm);
60 #define SIGN_EXT_S25(imm) sign_ext(25, imm);
82 case 5:
return RZ_TYPE_COND_?? - CS,
C,LO - Carry set & LO
83 case 6:
return RZ_TYPE_COND_?? - CC,
NC,HS - Carry clear & HS
85 case 0xf:
return RZ_TYPE_COND_?? - PNZ - Positive non-zero
108 case 0:
op->refptr = 4;
break;
109 case 1:
op->refptr = 1;
break;
110 case 2:
op->refptr = 2;
break;
122 switch (basic_type) {
137 f->cond =
f->a & 0x1f;
143 op->type = basic_type;
151 op->delay =
f->mode_n;
154 op->type = type_ujmp;
157 op->type = basic_type;
161 op->type = basic_type;
162 f->imm = (
f->a << 6 |
f->c);
167 if (
f->mode_m == 0) {
169 op->type = type_cjmp;
178 op->delay =
f->mode_n;
183 op->type = type_ucjmp;
187 op->type = type_cjmp;
199 fields.format = (words[0] & 0x00c00000) >> 22;
200 fields.subopcode = (words[0] & 0x003f0000) >> 16;
201 fields.c = (words[0] & 0x00000fc0) >> 6;
202 fields.a = (words[0] & 0x0000003f);
203 fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
225 }
else if (
fields.format == 2) {
230 switch (
fields.subopcode) {
274 }
else if (
fields.format == 3) {
303 fields.mode_m = (words[0] & 0x20) >> 5;
310 fields.mode_m = (words[0] & 0x20) >> 5;
475 fields.opcode = (words[0] & 0xf8000000) >> 27;
477 op->size = (
fields.opcode >= 0x0c) ? 2 : 4;
478 op->nopcode =
op->size;
482 fields.format = (words[0] & 0x00010000) >> 16;
483 fields.a = (words[0] & 0x07fe0000) >> 17;
484 fields.b = (words[0] & 0x0000ffc0) >> 6;
485 fields.c = (words[0] & 0x0000000f);
486 fields.mode_n = (words[0] & 0x20) >> 5;
492 fields.cond = (words[0] & 0x1f);
506 fields.format = (words[0] & 0x00010000) >> 16;
507 fields.mode_n = (words[0] & 0x20) >> 5;
510 fields.format2 = (words[0] & 0x10) >> 4;
511 fields.subopcode = (words[0] & 0x0f);
512 fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
513 fields.c = (words[0] & 0x00000fc0) >> 6;
514 fields.imm =
SIGN_EXT_S9((words[0] & 0x00fe0000) >> 16 | (words[0] & 0x8000) >> 7);
517 if (
fields.format2 == 0) {
530 fields.format2 = (words[0] & 0x00020000) >> 17;
531 fields.a = (words[0] & 0x07fc0000) >> 18;
532 fields.b = (words[0] & 0x0000ffc0) >> 6;
533 fields.c = (words[0] & 0x0000000f);
536 if (
fields.format2 == 0) {
539 fields.cond = (words[0] & 0x1f);
554 fields.a = (words[0] & 0x0000003f);
555 fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
556 fields.imm =
SIGN_EXT_S9((words[0] & 0x00ff0000) >> 16 | (words[0] & 0x8000) >> 7);
558 fields.mode_zz = (words[0] & 0x180) >> 7;
580 fields.c = (words[0] & 0xfc0) >> 6;
581 fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
582 fields.imm =
SIGN_EXT_S9((words[0] & 0x00ff0000) >> 16 | (words[0] & 0x8000) >> 7);
584 fields.mode_zz = (words[0] & 0x6) >> 1;
612 fields.subopcode = (words[0] & 0x003f0000) >> 16;
613 fields.format = (words[0] & 0x00c00000) >> 22;
614 fields.c = (words[0] & 0x00000fc0) >> 6;
615 fields.a = (words[0] & 0x0000003f);
616 fields.b = (words[0] & 0x07000000) >> 24 | (words[0] & 0x7000) >> 9;
643 fields.subopcode = (words[0] & 0x00180000) >> 19;
648 switch (
fields.subopcode) {
660 fields.subopcode = (words[0] & 0x00180000) >> 19;
665 switch (
fields.subopcode) {
681 fields.subopcode = (words[0] & 0x00180000) >> 19;
683 fields.c = (words[0] & 0x00e00000) >> 21 | (words[0] & 0x00070000) >> 13;
687 op->val = (words[0] & 0x0000ffff) << 16 | (words[1] & 0xffff0000) >> 16;
690 switch (
fields.subopcode) {
704 fields.subopcode = (words[0] & 0x001f0000) >> 16;
705 fields.c = (words[0] & 0x00e00000) >> (16 + 5);
706 fields.b = (words[0] & 0x07000000) >> (16 + 8);
708 switch (
fields.subopcode) {
858 fields.subopcode = (words[0] & 0x00e00000) >> (16 + 5);
859 switch (
fields.subopcode) {
883 fields.subopcode = (words[0] & 0x00e00000) >> (16 + 5);
884 switch (
fields.subopcode) {
897 fields.b = (words[0] & 0x07000000) >> (16 + 8);
911 fields.c = (words[0] & 0x001f0000) >> 16;
923 fields.c = (words[0] & 0x001f0000) >> 16;
937 fields.subopcode = (words[0] & 0x06000000) >> (16 + 9);
938 switch (
fields.subopcode) {
951 fields.c = (words[0] & 0x00ff0000) >> 14;
957 op->val = (words[0] & 0x00ff0000) >> 16;
961 fields.subopcode = (words[0] & 0x00800000) >> (16 + 7);
962 if (
fields.subopcode == 0) {
976 fields.subopcode = (words[0] & 0x06000000) >> (16 + 9);
978 switch (
fields.subopcode) {
1010 if (analysis->
bits == 16) {
1017 ut8 basecode = (
len > 3) ? ((
b[3] & 0xf8) >> 3) : 0;
1044 if ((
b[0] == 0xff) && (
b[1] == 0xff)) {
1060 if (analysis->
bits != 16) {
1077 if (analysis->
bits != 16) {
1100 "gpr r10 .32 40 0\n"
1101 "gpr r11 .32 44 0\n"
1102 "gpr r12 .32 48 0\n"
1103 "gpr r13 .32 52 0\n"
1104 "gpr r14 .32 56 0\n"
1105 "gpr r15 .32 60 0\n"
1106 "gpr r16 .32 64 0\n"
1107 "gpr r17 .32 68 0\n"
1108 "gpr r18 .32 72 0\n"
1109 "gpr r19 .32 76 0\n"
1110 "gpr r20 .32 80 0\n"
1111 "gpr r21 .32 84 0\n"
1112 "gpr r22 .32 88 0\n"
1113 "gpr r23 .32 92 0\n"
1114 "gpr r24 .32 96 0\n"
1115 "gpr r25 .32 100 0\n"
1116 "gpr gp .32 104 0\n"
1117 "gpr fp .32 108 0\n"
1118 "gpr sp .32 112 0\n"
1119 "gpr ilink1 .32 116 0\n"
1120 "gpr ilink2 .32 120 0\n"
1121 "gpr blink .32 124 0\n"
1122 "gpr lp_count .32 128 0\n"
1123 "gpr pcl .32 132 0\n";
1136 .desc =
"ARC code analysis plugin",
1142 #ifndef RZ_PLUGIN_INCORE
const aarch64_field fields[]
#define SIGN_EXT_S12(imm)
static void arcompact_branch(RzAnalysisOp *op, ut64 addr, st64 offset, ut8 delay)
static int map_cond2rizin(ut8 cond)
static char * get_reg_profile(RzAnalysis *analysis)
static int arcompact_genops(RzAnalysisOp *op, ut64 addr, ut32 words[2])
#define SIGN_EXT_S21(imm)
RzAnalysisPlugin rz_analysis_plugin_arc
static void arcompact_jump(RzAnalysisOp *op, ut64 addr, ut64 jump, ut8 delay)
RZ_API RzLibStruct rizin_plugin
static void map_zz2refptr(RzAnalysisOp *op, ut8 mode_zz)
static ut32 rz_read_me32_arc(const void *src)
#define SIGN_EXT_S10(imm)
static int arcompact_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len)
static int arc_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
static int archinfo(RzAnalysis *analysis, int query)
static int arcompact_genops_jmp(RzAnalysisOp *op, ut64 addr, arc_fields *f, ut64 basic_type)
static int sign_ext(int bits, int imm)
struct arc_fields_t arc_fields
#define SIGN_EXT_S25(imm)
static void arcompact_jump_cond(RzAnalysisOp *op, ut64 addr, ut64 jump, ut8 delay, ut8 cond)
#define SIGN_EXT_S13(imm)
int bits(struct state *s, int need)
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")
#define RZ_ANALYSIS_ARCHINFO_ALIGN
#define RZ_ANALYSIS_ARCHINFO_MAX_OP_SIZE
#define RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE
@ RZ_ANALYSIS_OP_TYPE_CMP
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_UNK
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_ROL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_SAL
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_UCCALL
@ RZ_ANALYSIS_OP_TYPE_ROR
@ RZ_ANALYSIS_OP_TYPE_SWI
@ RZ_ANALYSIS_OP_TYPE_SAR
@ RZ_ANALYSIS_OP_TYPE_ABS
@ RZ_ANALYSIS_OP_TYPE_NULL
@ RZ_ANALYSIS_OP_TYPE_CMOV
@ RZ_ANALYSIS_OP_TYPE_TRAP
@ RZ_ANALYSIS_OP_TYPE_XCHG
@ RZ_ANALYSIS_OP_TYPE_CCALL
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_CPL
@ RZ_ANALYSIS_OP_TYPE_CRET
@ RZ_ANALYSIS_OP_TYPE_PUSH
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_POP
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_UCJMP
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_ILL
@ RZ_ANALYSIS_OP_TYPE_UCALL
@ RZ_ANALYSIS_OP_TYPE_NOT
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_NOP
@ RZ_ANALYSIS_OP_TYPE_XOR
static ut32 rz_read_le32(const void *src)
static ut32 rz_read_be32(const void *src)
@ RZ_TYPE_COND_VS
Overflow Unordered.
@ RZ_TYPE_COND_LE
Less or equal.
@ RZ_TYPE_COND_GE
Greater or equal.
@ RZ_TYPE_COND_VC
No overflow Not unordered.
@ RZ_TYPE_COND_LS
Unsigned lower or same Less than or equal.
@ RZ_TYPE_COND_NE
Not equal.
@ RZ_TYPE_COND_AL
Always executed (no condition)
@ RZ_TYPE_COND_MI
Minus, negative Less than.
@ RZ_TYPE_COND_HI
Unsigned higher Greater than, or unordered.
@ RZ_TYPE_COND_GT
Greater than.
@ RZ_TYPE_COND_PL
Plus, positive or zero >, ==, or unordered.
@ RZ_TYPE_COND_LT
Less than.
#define cond(bop, top, mask, flags)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()