More fixes for MIPS and ESIL emulation

This commit is contained in:
pancake 2016-02-22 01:43:45 +01:00
parent f7fbbc419e
commit 3e1590f4d9
3 changed files with 17 additions and 8 deletions

View File

@ -701,7 +701,7 @@ static int esil_trap(RAnalEsil *esil) {
esil->trap_code = d;
return r_anal_esil_fire_trap (esil, (int)s, (int)d);
}
eprintf ("esil_trap: missing parameters in stack\n");
eprintf ("0x%08"PFMT64x" esil_trap: missing parameters in stack\n", esil->address);
return false;
}
@ -1272,11 +1272,11 @@ static int esil_inceq(RAnalEsil *esil) {
static int esil_sub(RAnalEsil *esil) {
ut64 s = 0, d = 0;
if (!popRN (esil, &d)) {
eprintf ("esil_sub: dst is broken\n");
eprintf ("0x%08"PFMT64x" esil_sub: dst is broken\n", esil->address);
return false;
}
if (!popRN (esil, &s)) {
eprintf ("esil_sub: src is broken\n");
eprintf ("0x%08"PFMT64x" esil_sub: src is broken\n", esil->address);
return false;
}
r_anal_esil_pushnum (esil, d - s);
@ -2027,11 +2027,11 @@ static int esil_smaller(RAnalEsil *esil) { // 'src < dst' => 'src,dst,<'
static int esil_bigger(RAnalEsil *esil) { // 'src > dst' => 'src,dst,>'
ut64 s, d;
if (!popRN (esil, &d)) {
eprintf ("esil_bigger: src is broken\n");
eprintf ("0x%08"PFMT64x" esil_bigger: src is broken\n", esil->address);
return false;
}
if (!popRN (esil, &s)) {
eprintf ("esil_bigger: dst is broken\n");
eprintf ("0x%08"PFMT64x" esil_bigger: dst is broken\n", esil->address);
return false;
}
r_anal_esil_pushnum (esil, (d > s));

View File

@ -146,7 +146,7 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
r_strbuf_setf (&op->esil, ",");
break;
case MIPS_INS_BREAK:
r_strbuf_setf (&op->esil, "%s,%s,TRAP", ARG (1), ARG (0));
r_strbuf_setf (&op->esil, "%s,%s,TRAP", ARG (0), ARG (0));
break;
case MIPS_INS_SW:
case MIPS_INS_SWL:
@ -314,8 +314,10 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_FSUB:
case MIPS_INS_SUB:
PROTECT_ZERO () {
r_strbuf_appendf(&op->esil, "%s,%s,>,?{,1,TRAP,}{,%s,%s,-,%s,=",
ARG (1), ARG (2), ARG (1), ARG (2), ARG (0));
r_strbuf_appendf(&op->esil, "%s,%s,-,%s,=",
ARG (1), ARG (2), ARG (0));
//r_strbuf_appendf(&op->esil, "%s,%s,>,?{,1,TRAP,}{,%s,%s,-,%s,=",
// ARG (1), ARG (2), ARG (1), ARG (2), ARG (0));
}
break;
case MIPS_INS_SUBU:
@ -339,9 +341,13 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_ADD:
{
PROTECT_ZERO () {
r_strbuf_appendf(&op->esil, "%s,%s,-,%s,=",
ARG (1), ARG (2), ARG (0));
#if 0
r_strbuf_appendf (&op->esil,
"0,32,%s,%s,+,>>,>,?{,1,TRAP,}{,%s,%s,+,%s,=,}",
ARG(2), ARG(1), ARG(2), ARG(1), ARG(0));
#endif
}
}
break;

View File

@ -313,6 +313,9 @@ static int init_dynamic_section (struct Elf_(r_bin_elf_obj_t) *bin) {
}
if (!strtabaddr || strtabaddr > bin->size ||
strsize > ST32_MAX || strsize == 0 || strsize > bin->size) {
if (!strtabaddr) {
eprintf ("Warning: section.shstrtab not found or invalid\n");
}
free (dyn);
return false;
}