Extend arm64 regprofile for 16 and 8bit registers

This commit is contained in:
pancake 2016-08-30 23:21:23 +02:00
parent bf6f4c5477
commit dc7d65c07a
2 changed files with 77 additions and 13 deletions

View File

@ -9,19 +9,19 @@
#define IMM64(x) insn->detail->arm64.operands[x].imm
/* arm32 */
#define REG(x) cs_reg_name (*handle, insn->detail->arm.operands[x].reg)
#define REG64(x) cs_reg_name (*handle, insn->detail->arm64.operands[x].reg)
#define REG(x) r_str_get (cs_reg_name (*handle, insn->detail->arm.operands[x].reg))
#define REG64(x) r_str_get (cs_reg_name (*handle, insn->detail->arm64.operands[x].reg))
#define REGID64(x) insn->detail->arm64.operands[x].reg
#define REGID(x) insn->detail->arm.operands[x].reg
#define IMM(x) (ut32)(insn->detail->arm.operands[x].imm)
#define IMM64(x) insn->detail->arm64.operands[x].imm
#define MEMBASE(x) cs_reg_name(*handle, insn->detail->arm.operands[x].mem.base)
#define MEMBASE64(x) cs_reg_name(*handle, insn->detail->arm64.operands[x].mem.base)
#define MEMBASE(x) r_str_get (cs_reg_name(*handle, insn->detail->arm.operands[x].mem.base))
#define MEMBASE64(x) r_str_get (cs_reg_name(*handle, insn->detail->arm64.operands[x].mem.base))
#define REGBASE(x) insn->detail->arm.operands[x].mem.base
#define REGBASE64(x) insn->detail->arm64.operands[x].mem.base
// s/index/base|reg/
#define MEMINDEX(x) cs_reg_name(*handle, insn->detail->arm.operands[x].mem.index)
#define MEMINDEX64(x) cs_reg_name(*handle, insn->detail->arm64.operands[x].mem.index)
#define MEMINDEX(x) r_str_get (cs_reg_name(*handle, insn->detail->arm.operands[x].mem.index))
#define MEMINDEX64(x) r_str_get (cs_reg_name(*handle, insn->detail->arm64.operands[x].mem.index))
#define HASMEMINDEX64(x) insn->detail->arm64.operands[x].mem.index != ARM64_REG_INVALID
#define MEMDISP(x) insn->detail->arm.operands[x].mem.disp
#define MEMDISP64(x) insn->detail->arm64.operands[x].mem.disp
@ -145,13 +145,13 @@ static const char *arg(RAnal *a, csh *handle, cs_insn *insn, char *buf, int n) {
if (ISSHIFTED (n)) {
sprintf (buf, "%u,%s,%s",
LSHIFT2 (n),
cs_reg_name (*handle,
insn->detail->arm.operands[n].reg),
r_str_get (cs_reg_name (*handle,
insn->detail->arm.operands[n].reg)),
DECODE_SHIFT (n));
} else {
sprintf (buf, "%s",
cs_reg_name (*handle,
insn->detail->arm.operands[n].reg));
r_str_get (cs_reg_name (*handle,
insn->detail->arm.operands[n].reg)));
}
break;
case ARM_OP_IMM:
@ -1451,6 +1451,72 @@ static char *get_reg_profile(RAnal *anal) {
"=CF cf\n"
"=SN x0\n"
/* 8bit sub-registers */
"gpr b0 .8 0 0\n"
"gpr b1 .8 8 0\n"
"gpr b2 .8 16 0\n"
"gpr b3 .8 24 0\n"
"gpr b4 .8 32 0\n"
"gpr b5 .8 40 0\n"
"gpr b6 .8 48 0\n"
"gpr b7 .8 56 0\n"
"gpr b8 .8 64 0\n"
"gpr b9 .8 72 0\n"
"gpr b10 .8 80 0\n"
"gpr b11 .8 88 0\n"
"gpr b12 .8 96 0\n"
"gpr b13 .8 104 0\n"
"gpr b14 .8 112 0\n"
"gpr b15 .8 120 0\n"
"gpr b16 .8 128 0\n"
"gpr b17 .8 136 0\n"
"gpr b18 .8 144 0\n"
"gpr b19 .8 152 0\n"
"gpr b20 .8 160 0\n"
"gpr b21 .8 168 0\n"
"gpr b22 .8 176 0\n"
"gpr b23 .8 184 0\n"
"gpr b24 .8 192 0\n"
"gpr b25 .8 200 0\n"
"gpr b26 .8 208 0\n"
"gpr b27 .8 216 0\n"
"gpr b28 .8 224 0\n"
"gpr b29 .8 232 0\n"
"gpr b30 .8 240 0\n"
/* 16bit sub-registers */
"gpr h0 .16 0 0\n"
"gpr h1 .16 8 0\n"
"gpr h2 .16 16 0\n"
"gpr h3 .16 24 0\n"
"gpr h4 .16 32 0\n"
"gpr h5 .16 40 0\n"
"gpr h6 .16 48 0\n"
"gpr h7 .16 56 0\n"
"gpr h8 .16 64 0\n"
"gpr h9 .16 72 0\n"
"gpr h10 .16 80 0\n"
"gpr h11 .16 88 0\n"
"gpr h12 .16 96 0\n"
"gpr h13 .16 104 0\n"
"gpr h14 .16 112 0\n"
"gpr h15 .16 120 0\n"
"gpr h16 .16 128 0\n"
"gpr h17 .16 136 0\n"
"gpr h18 .16 144 0\n"
"gpr h19 .16 152 0\n"
"gpr h20 .16 160 0\n"
"gpr h21 .16 168 0\n"
"gpr h22 .16 176 0\n"
"gpr h23 .16 184 0\n"
"gpr h24 .16 192 0\n"
"gpr h25 .16 200 0\n"
"gpr h26 .16 208 0\n"
"gpr h27 .16 216 0\n"
"gpr h28 .16 224 0\n"
"gpr h29 .16 232 0\n"
"gpr h30 .16 240 0\n"
/* 32bit sub-registers */
"gpr w0 .32 0 0\n"
"gpr w1 .32 8 0\n"

View File

@ -779,9 +779,7 @@ R_API char *r_str_word_get_first(const char *text) {
}
R_API const char *r_str_get(const char *str) {
if (str == NULL)
return nullstr_c;
return str;
return str? str: nullstr_c;
}
R_API char *r_str_ndup(const char *ptr, int len) {