From 3e1590f4d971cc2241f2238f9bdae88eaa06259d Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 22 Feb 2016 01:43:45 +0100 Subject: [PATCH] More fixes for MIPS and ESIL emulation --- libr/anal/esil.c | 10 +++++----- libr/anal/p/anal_mips_cs.c | 12 +++++++++--- libr/bin/format/elf/elf.c | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libr/anal/esil.c b/libr/anal/esil.c index c3c08a0f2d..9d335132f8 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -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)); diff --git a/libr/anal/p/anal_mips_cs.c b/libr/anal/p/anal_mips_cs.c index 24658971a9..73e6a4e66f 100644 --- a/libr/anal/p/anal_mips_cs.c +++ b/libr/anal/p/anal_mips_cs.c @@ -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; diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 585f297947..75a57abd1b 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -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; }