Skip to content

Commit

Permalink
Fix radareorg#9197, wrong esil for aarch64 ldr (radareorg#9442)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscri authored and radare committed Feb 20, 2018
1 parent 0c776c0 commit d08115b
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions libr/anal/p/anal_arm_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,53 +1022,51 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l
default:
break;
}
if ((int)MEMDISP64(1) < 0) {
r_strbuf_setf (&op->esil, "%s,%s,%"PFMT64d",-,=[%d]",
REG64(0), MEMBASE64(1), -(int)MEMDISP64(1), size);
} else {
if (ISMEM64(1)) {
if (HASMEMINDEX64(1)) {
if (LSHIFT2_64(1)) {
r_strbuf_appendf (&op->esil, "%s,%d,%s,%s,+,[%d],%s,=",
MEMBASE64(1), LSHIFT2_64(1), MEMINDEX64(1), DECODE_SHIFT64(1), size, REG64(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%s,+,[%d],%s,=",
MEMBASE64(1), MEMINDEX64(1), size, REG64(0));
}
if (ISMEM64(1)) {
if (HASMEMINDEX64(1)) {
if (LSHIFT2_64(1)) {
r_strbuf_appendf (&op->esil, "%s,%d,%s,%s,+,[%d],%s,=",
MEMBASE64(1), LSHIFT2_64(1), MEMINDEX64(1), DECODE_SHIFT64(1), size, REG64(0));
} else {
if (LSHIFT2_64(1)) {
r_strbuf_appendf (&op->esil, "%s,%d,%"PFMT64d",%s,+,[%d],%s,=",
MEMBASE64(1), LSHIFT2_64(1), MEMDISP64(1), DECODE_SHIFT64(1), size, REG64(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%"PFMT64d",+,DUP,tmp,=,[%d],%s,=,",
MEMBASE64(1), MEMDISP64(1), size, REG64(0));
}
r_strbuf_appendf (&op->esil, "%s,%s,+,[%d],%s,=",
MEMBASE64(1), MEMINDEX64(1), size, REG64(0));
}
op->refptr = 4;
} else {
if (ISREG64(1)) {
if (OPCOUNT64() == 2) {
r_strbuf_setf (&op->esil, "%s,[%d],%s,=",
REG64(1), size, REG64(0));
} else if (OPCOUNT64() == 3) {
/*
This seems like a capstone bug:
instructions like
ldr x16, [x13, x9]
ldrb w2, [x19, x23]
are not detected as ARM64_OP_MEM type and
fall in this case instead.
*/
if (ISREG64(2)) {
r_strbuf_setf (&op->esil, "%s,%s,+,[%d],%s,=",
REG64(1), REG64(2), size, REG64(0));
}
}
if (LSHIFT2_64(1)) {
r_strbuf_appendf (&op->esil, "%s,%d,%"PFMT64d",%s,+,[%d],%s,=",
MEMBASE64(1), LSHIFT2_64(1), MEMDISP64(1), DECODE_SHIFT64(1), size, REG64(0));
} else if ((int)MEMDISP64(1) < 0){
r_strbuf_appendf (&op->esil, "%"PFMT64d",%s,-,DUP,tmp,=,[%d],%s,=,",
-(int)MEMDISP64(1), MEMBASE64(1), size, REG64(0));
} else {
r_strbuf_setf (&op->esil, "%"PFMT64d",[%d],%s,=",
IMM64(1), size, REG64(0));
r_strbuf_appendf (&op->esil, "%s,%"PFMT64d",+,DUP,tmp,=,[%d],%s,=,",
MEMBASE64(1), MEMDISP64(1), size, REG64(0));
}
}
op->refptr = 4;
} else {
if (ISREG64(1)) {
if (OPCOUNT64() == 2) {
r_strbuf_setf (&op->esil, "%s,[%d],%s,=",
REG64(1), size, REG64(0));
} else if (OPCOUNT64() == 3) {
/*
This seems like a capstone bug:
instructions like
ldr x16, [x13, x9]
ldrb w2, [x19, x23]
are not detected as ARM64_OP_MEM type and
fall in this case instead.
*/
if (ISREG64(2)) {
r_strbuf_setf (&op->esil, "%s,%s,+,[%d],%s,=",
REG64(1), REG64(2), size, REG64(0));
}
}
} else {
r_strbuf_setf (&op->esil, "%"PFMT64d",[%d],%s,=",
IMM64(1), size, REG64(0));
}
}
break;
}
Expand Down

0 comments on commit d08115b

Please sign in to comment.