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
------------------------------------------------------------------ */
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,
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
------------------------------------------------------------------ */