]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't allow vex to chase into any block for which we might want to create
authorJulian Seward <jseward@acm.org>
Thu, 7 Jul 2005 13:52:53 +0000 (13:52 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 7 Jul 2005 13:52:53 +0000 (13:52 +0000)
a self-checking translation.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4126

coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_translate.c

index 4c66ec1a57396c8cda28b895d11ca87c4c03ac5d..e5fea3375aed7b9411a164e162e045acf73bbfaa 100644 (file)
@@ -222,7 +222,7 @@ static Int allocate_segname ( const HChar* name )
    an address after it, and 0 if it denotes an address covered by
    seg. 
 */
-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) 
       return -1;
index 9d28c173e387d8f98ca263ee2fd780a2c96a364f..b49c30ec15f806faa066715dd2acafd6320288ff 100644 (file)
@@ -380,18 +380,46 @@ void log_bytes ( HChar* bytes, Int nbytes )
 /* 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 = (Addr)addr64;
-  if (addr != 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 = (Addr)addr64;
+
+   /* All chasing disallowed if all bbs require self-checks. */
+   if (VG_(clo_smc_support) == 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) == Vg_SmcStack) {
+      Segment* seg = VG_(find_segment)(addr);
+      if (seg && (seg->flags & SF_GROWDOWN))
+         goto dontchase;
+   }
+
+   /* Destination is redirected? */
+   if (addr != 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;
 }
 
+
 Bool VG_(translate) ( ThreadId tid, 
                       Addr64   orig_addr,
                       Bool     debugging_translation,
@@ -509,6 +537,7 @@ Bool VG_(translate) ( ThreadId tid,
       case Vg_SmcNone:  do_self_check = False; break;
       case Vg_SmcAll:   do_self_check = True;  break;
       case Vg_SmcStack: 
+         /* XXXYYYZZZ: must match the logic at AAABBBCCC above */
          do_self_check = seg ? toBool(seg->flags & SF_GROWDOWN) : False;
          break;
       default: vg_assert2(0, "unknown VG_(clo_smc_support) value");