Skip to content

Commit

Permalink
More fixes for MIPS and ESIL emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Feb 22, 2016
1 parent f7fbbc4 commit 3e1590f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions libr/anal/esil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 9 additions & 3 deletions libr/anal/p/anal_mips_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions libr/bin/format/elf/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3e1590f

Please sign in to comment.