|
From: <sv...@va...> - 2005-07-07 13:52:59
|
Author: sewardj
Date: 2005-07-07 14:52:53 +0100 (Thu, 07 Jul 2005)
New Revision: 4126
Log:
Don't allow vex to chase into any block for which we might want to create
a self-checking translation.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
trunk/coregrind/m_translate.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr.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/coregrind/m_aspacemgr/aspacemgr.c 2005-07-07 13:20:31 UTC (rev =
4125)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-07-07 13:52:53 UTC (rev =
4126)
@@ -222,7 +222,7 @@
an address after it, and 0 if it denotes an address covered by
seg.=20
*/
-static Int compare_addr_with_seg ( Addr a, Segment* seg )
+static inline Int compare_addr_with_seg ( Addr a, Segment* seg )
{
if (a < seg->addr)=20
return -1;
Modified: trunk/coregrind/m_translate.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/coregrind/m_translate.c 2005-07-07 13:20:31 UTC (rev 4125)
+++ trunk/coregrind/m_translate.c 2005-07-07 13:52:53 UTC (rev 4126)
@@ -380,18 +380,46 @@
/* This stops Vex from chasing into function entry points that we wish
to redirect. Chasing across them obviously defeats the redirect
mechanism, with bad effects for Memcheck, Addrcheck, and possibly
- others. */
+ others.
+
+ Also, we must stop Vex chasing into blocks for which we might want
+ to self checking.
+*/
static Bool chase_into_ok ( Addr64 addr64 )
{
- Addr addr =3D (Addr)addr64;
- if (addr !=3D VG_(code_redirect)(addr)) {
- if (0) VG_(printf)("not chasing into 0x%x\n", addr);
- return False;
- } else {
- return True; /* ok to chase into 'addr' */
- }
+ /* Work through a list of possibilities why we might not want to
+ allow a chase. */
+ Addr addr =3D (Addr)addr64;
+
+ /* All chasing disallowed if all bbs require self-checks. */
+ if (VG_(clo_smc_support) =3D=3D Vg_SmcAll)
+ goto dontchase;
+
+ /* AAABBBCCC: if default self-checks are in force, reject if we
+ would choose to have a self-check for the dest. Note, this must
+ match the logic at XXXYYYZZZ below. */
+ if (VG_(clo_smc_support) =3D=3D Vg_SmcStack) {
+ Segment* seg =3D VG_(find_segment)(addr);
+ if (seg && (seg->flags & SF_GROWDOWN))
+ goto dontchase;
+ }
+
+ /* Destination is redirected? */
+ if (addr !=3D VG_(code_redirect)(addr))
+ goto dontchase;
+
+ /* well, ok then. go on and chase. */
+ return True;
+
+ vg_assert(0);
+ /*NOTREACHED*/
+
+ dontchase:
+ if (0) VG_(printf)("not chasing into 0x%x\n", addr);
+ return False;
}
=20
+
Bool VG_(translate) ( ThreadId tid,=20
Addr64 orig_addr,
Bool debugging_translation,
@@ -509,6 +537,7 @@
case Vg_SmcNone: do_self_check =3D False; break;
case Vg_SmcAll: do_self_check =3D True; break;
case Vg_SmcStack:=20
+ /* XXXYYYZZZ: must match the logic at AAABBBCCC above */
do_self_check =3D seg ? toBool(seg->flags & SF_GROWDOWN) : Fals=
e;
break;
default: vg_assert2(0, "unknown VG_(clo_smc_support) value");
|