Fix jalx for mips.gnu and mips.cs

This commit is contained in:
pancake 2014-12-09 02:21:58 +01:00
parent e36d2d4dcf
commit 2d81508caf
4 changed files with 22 additions and 11 deletions

View File

@ -220,7 +220,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
}
#endif
op->size = opsize;
op->delay = 1;
//op->delay = 1;
return opsize;
}

View File

@ -92,6 +92,7 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len
case MIPS_INS_BAL:
case MIPS_INS_JAL:
case MIPS_INS_JALR:
case MIPS_INS_JALRS:
case MIPS_INS_JALRC:
case MIPS_INS_BLTZAL: // Branch on less than zero and link
r_strbuf_appendf (&op->esil, "pc,8,+,ra,=,%s,pc,=", ARG(0));
@ -375,9 +376,13 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
op->type = R_ANAL_OP_TYPE_UCALL;
op->delay = 1;
break;
case MIPS_INS_BAL:
case MIPS_INS_JAL:
case MIPS_INS_JALRC:
case MIPS_INS_JALS:
case MIPS_INS_JALX:
case MIPS_INS_JIALC:
case MIPS_INS_JIC:
case MIPS_INS_JRADDIUSP:
case MIPS_INS_BAL:
case MIPS_INS_BGEZAL: // Branch on less than zero and link
op->type = R_ANAL_OP_TYPE_CALL;
op->delay = 1;

View File

@ -88,11 +88,6 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b_in, int len
break;
case 7: // srav
break;
case 9: // jalr
//eprintf ("%llx jalr\n", addr);
op->type = R_ANAL_OP_TYPE_UCALL;
op->delay = 1;
break;
case 8: // jr
//eprintf ("%llx jr\n", addr);
// TODO: check return value or gtfo
@ -103,6 +98,11 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b_in, int len
}
op->delay = 1;
break;
case 9: // jalr
//eprintf ("%llx jalr\n", addr);
op->type = R_ANAL_OP_TYPE_UCALL;
op->delay = 1;
break;
case 12: // syscall
op->type = R_ANAL_OP_TYPE_SWI;
break;
@ -308,6 +308,12 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b_in, int len
case 49: // lwc1
case 57: // swc1
break;
case 29: // jalx
op->type = R_ANAL_OP_TYPE_CALL;
op->jump = addr + 4*((b[3] | b[2]<<8 | b[1]<<16));
op->fail = addr + 8;
op->delay = 1;
break;
}
//family = 'I';
}

View File

@ -998,9 +998,9 @@ print_insn_args (const char *d,
info->target = (((pc + 4) & ~(bfd_vma) 0x0fffffff)
| (((l >> OP_SH_TARGET) & OP_MASK_TARGET) << 2));
/* For gdb disassembler, force odd address on jalx. */
if (info->flavour == bfd_target_unknown_flavour
&& strcmp (opp->name, "jalx") == 0)
info->target |= 1;
//if (info->flavour == bfd_target_unknown_flavour
// && strcmp (opp->name, "jalx") == 0)
//info->target |= 1;
(*info->print_address_func) (info->target, info);
break;