|
From: <sv...@va...> - 2008-04-14 10:17:36
|
Author: sewardj
Date: 2008-04-14 11:17:36 +0100 (Mon, 14 Apr 2008)
New Revision: 1824
Log:
Fix redzone abi-hinting on ppc, so as to pass NIA. Also, pass a
call-style hint for bctrl, instead of no hint.
Modified:
branches/OTRACK_BY_INSTRUMENTATION/priv/guest-ppc/toIR.c
Modified: branches/OTRACK_BY_INSTRUMENTATION/priv/guest-ppc/toIR.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/priv/guest-ppc/toIR.c 2008-04-09 01:03:14 UTC (rev 1823)
+++ branches/OTRACK_BY_INSTRUMENTATION/priv/guest-ppc/toIR.c 2008-04-14 10:17:36 UTC (rev 1824)
@@ -1211,27 +1211,31 @@
/* Generate AbiHints which mark points at which the ELF or PowerOpen
ABIs say that the stack red zone (viz, -N(r1) .. -1(r1), for some
N) becomes undefined. That is at function calls and returns. ELF
- ppc32 doesn't have this "feature" (how fortunate for it).
+ ppc32 doesn't have this "feature" (how fortunate for it). nia is
+ the address of the next instruction to be executed.
*/
-static void make_redzone_AbiHint ( VexAbiInfo* vbi, HChar* who )
+static void make_redzone_AbiHint ( VexAbiInfo* vbi,
+ IRTemp nia, HChar* who )
{
Int szB = vbi->guest_stack_redzone_size;
if (0) vex_printf("AbiHint: %s\n", who);
-vassert(0); /*FIXME*/
vassert(szB >= 0);
if (szB > 0) {
- if (mode64)
+ if (mode64) {
+ vassert(typeOfIRTemp(irsb->tyenv, nia) == Ity_I64);
stmt( IRStmt_AbiHint(
binop(Iop_Sub64, getIReg(1), mkU64(szB)),
- szB
-,mkU64(0)
+ szB,
+ mkexpr(nia)
));
- else
+ } else {
+ vassert(typeOfIRTemp(irsb->tyenv, nia) == Ity_I32);
stmt( IRStmt_AbiHint(
binop(Iop_Sub32, getIReg(1), mkU32(szB)),
- szB
-,mkU32(0)
+ szB,
+ mkexpr(nia)
));
+ }
}
}
@@ -4311,9 +4315,12 @@
if (flag_LK) {
putGST( PPC_GST_LR, e_nia );
if (vbi->guest_ppc_zap_RZ_at_bl
- && vbi->guest_ppc_zap_RZ_at_bl( (ULong)tgt) )
- make_redzone_AbiHint( vbi,
+ && vbi->guest_ppc_zap_RZ_at_bl( (ULong)tgt) ) {
+ IRTemp t_tgt = newTemp(ty);
+ assign(t_tgt, mode64 ? mkU64(tgt) : mkU32(tgt) );
+ make_redzone_AbiHint( vbi, t_tgt,
"branch-and-link (unconditional call)" );
+ }
}
if (resteerOkFn( callback_opaque, tgt )) {
@@ -4382,6 +4389,8 @@
assign( cond_ok, branch_cond_ok( BO, BI ) );
+ /* FIXME: this is confusing. lr_old holds the old value
+ of ctr, not lr :-) */
assign( lr_old, addr_align( getGST( PPC_GST_CTR ), 4 ));
if (flag_LK)
@@ -4391,7 +4400,12 @@
binop(Iop_CmpEQ32, mkexpr(cond_ok), mkU32(0)),
Ijk_Boring,
c_nia ));
-
+
+ if (flag_LK && vbi->guest_ppc_zap_RZ_at_bl) {
+ make_redzone_AbiHint( vbi, lr_old,
+ "b-ctr-l (indirect call)" );
+ }
+
irsb->jumpkind = flag_LK ? Ijk_Call : Ijk_Boring;
irsb->next = mkexpr(lr_old);
break;
@@ -4427,8 +4441,10 @@
Ijk_Boring,
c_nia ));
- if (vanilla_return && vbi->guest_ppc_zap_RZ_at_blr)
- make_redzone_AbiHint( vbi, "branch-to-lr (unconditional return)" );
+ if (vanilla_return && vbi->guest_ppc_zap_RZ_at_blr) {
+ make_redzone_AbiHint( vbi, lr_old,
+ "branch-to-lr (unconditional return)" );
+ }
/* blrl is pretty strange; it's like a return that sets the
return address of its caller to the insn following this
|