]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
On AMD64 it's valid to access up to 128 bytes below %rsp. Or to be
authorJulian Seward <jseward@acm.org>
Fri, 25 Feb 2005 02:45:39 +0000 (02:45 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 25 Feb 2005 02:45:39 +0000 (02:45 +0000)
more accurate, on the amd64-linux ABI that is allowable.  Anyway,
parameterise the signal handler so it isn't confused by such accesses.

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

coregrind/amd64/core_arch.h
coregrind/vg_signals.c
coregrind/x86/core_arch.h

index c7084497e6f18254a244b6d82071ecbaa1f5c6ab..16aaf37a4cf9a8db8495bcdb7003ff04cf11ed55 100644 (file)
    asm("movq %%rbp, %0" : "=r" (lval));      \
 } while (0)
 
+// On AMD64, it's ok to access up to 128 bytes below %rsp.
+// The signal handler needs to know this.
+#define ARCH_STACK_REDZONE_SIZE 128
+
 /* ---------------------------------------------------------------------
    Architecture-specific part of a ThreadState
    ------------------------------------------------------------------ */
index a46cdd3ef7b4c8f3ac4578c9c9965897e2aede68..bebdaa5d6accb89358060d94e0246be4864b32c2 100644 (file)
@@ -1781,17 +1781,17 @@ void vg_sync_signalhandler ( Int sigNo, vki_siginfo_t *info, struct vki_ucontext
                         VG_(shadow_base), VG_(shadow_end));
       }
 
-      if (info->si_code == 1           &&      /* SEGV_MAPERR */
-         seg != NULL                   &&
-         fault >= esp                  &&
-         fault < seg->addr             &&
+      if (info->si_code == 1                        && /* SEGV_MAPERR */
+         seg != NULL                               &&
+         fault >= (esp - ARCH_STACK_REDZONE_SIZE)  &&
+         fault < seg->addr                         &&
          (seg->flags & SF_GROWDOWN)) {
         /* If the fault address is above esp but below the current known
            stack segment base, and it was a fault because there was
            nothing mapped there (as opposed to a permissions fault),
            then extend the stack segment. 
         */
-        Addr base = PGROUNDDN(esp);
+        Addr base = PGROUNDDN(esp - ARCH_STACK_REDZONE_SIZE);
          if (seg->len + (seg->addr - base) <= VG_(threads)[tid].stack_size &&
              (void*)-1 != VG_(mmap)((Char *)base, seg->addr - base,
                               VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
index 471f15f75095f5d0d51b86f3e2b40bd3c57de277..9feb3a544d45bf13cc73b7e9e607a3f6dc59028e 100644 (file)
    asm("movl %%ebp, %0" : "=r" (ebp));       \
 } while (0)
 
+// On X86, any access below %esp is illegal.
+// The signal handler needs to know this.
+#define ARCH_STACK_REDZONE_SIZE 0
+
 /* ---------------------------------------------------------------------
    Architecture-specific part of a ThreadState
    ------------------------------------------------------------------ */