|
From: <sv...@va...> - 2005-10-08 11:28:24
|
Author: sewardj
Date: 2005-10-08 12:28:16 +0100 (Sat, 08 Oct 2005)
New Revision: 1417
Log:
Enable chasing of unconditional branches and calls.
Modified:
trunk/priv/guest-ppc32/toIR.c
Modified: trunk/priv/guest-ppc32/toIR.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-ppc32/toIR.c 2005-10-07 09:45:16 UTC (rev 1416)
+++ trunk/priv/guest-ppc32/toIR.c 2005-10-08 11:28:16 UTC (rev 1417)
@@ -2846,7 +2846,9 @@
/*
Integer Branch Instructions
*/
-static Bool dis_branch ( UInt theInstr, DisResult* dres )
+static Bool dis_branch ( UInt theInstr,=20
+ /*OUT*/DisResult* dres,
+ Bool (*resteerOkFn)(Addr64) )
{
UChar opc1 =3D toUChar((theInstr >> 26) & 0x3F); /* theInstr[2=
6:31] */
UChar BO =3D toUChar((theInstr >> 21) & 0x1F); /* theInstr[2=
1:25] */
@@ -2863,22 +2865,21 @@
=20
Addr32 nia =3D 0;
=20
- // IRTemp ctr =3D newTemp(Ity_I32);
- // IRTemp lr =3D newTemp(Ity_I32);
IRTemp ir_nia =3D newTemp(Ity_I32);
IRTemp do_branch =3D newTemp(Ity_I32);
IRTemp ctr_ok =3D newTemp(Ity_I32);
IRTemp cond_ok =3D newTemp(Ity_I32);
=20
-// assign( ctr, getSPR( PPC32_SPR_CTR ) );
-
/* Hack to pass through code that just wants to read the PC */
if (theInstr =3D=3D 0x429F0005) {
DIP("bcl 0x%x, 0x%x (a.k.a mr lr,cia+4)\n", BO, BI);
putSPR( PPC32_SPR_LR, mkU32(guest_CIA_curr_instr + 4) );
return True;
}
- =20
+
+ /* The default what-next. Individual cases can override it. */ =20
+ dres->whatNext =3D Dis_StopHere;
+
switch (opc1) {
case 0x12: // b (Branch, PPC32 p360)
if (flag_AA) {
@@ -2890,9 +2891,15 @@
=20
if (flag_LK) {
putSPR( PPC32_SPR_LR, mkU32(guest_CIA_curr_instr + 4) );
- } =20
- irbb->jumpkind =3D flag_LK ? Ijk_Call : Ijk_Boring;
- irbb->next =3D mkU32(nia);
+ }
+
+ if (resteerOkFn((Addr64)nia)) {
+ dres->whatNext =3D Dis_Resteer;
+ dres->continueAt =3D (Addr64)nia;
+ } else {
+ irbb->jumpkind =3D flag_LK ? Ijk_Call : Ijk_Boring;
+ irbb->next =3D mkU32(nia);
+ }
break;
=20
case 0x10: // bc (Branch Conditional, PPC32 p361)
@@ -3006,12 +3013,12 @@
return False;
}
break;
+
default:
vex_printf("dis_int_branch(PPC32)(opc1)\n");
return False;
}
=20
- dres->whatNext =3D Dis_StopHere;
return True;
}
=20
@@ -6659,7 +6666,7 @@
=20
/* Branch Instructions */
case 0x12: case 0x10: // b, bc
- if (dis_branch(theInstr, &dres)) goto decode_success;
+ if (dis_branch(theInstr, &dres, resteerOkFn)) goto decode_success;
goto decode_failure;
=20
/* System Linkage Instructions */
@@ -6776,7 +6783,7 @@
=20
/* Branch Instructions */
case 0x210: case 0x010: // bcctr, bclr
- if (dis_branch(theInstr, &dres)) goto decode_success;
+ if (dis_branch(theInstr, &dres, resteerOkFn)) goto decode_su=
ccess;
goto decode_failure;
=20
/* Memory Synchronization Instructions */
|