From 951611cf060cc3977db76fb05a252e981a227484 Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Mon, 9 May 2016 21:02:47 -0700
Subject: [PATCH] Add RELOCATABLE_STACK_START to control stack spaces

When RELOCATABLE_STACK_START is defined, the control stack, binding
stack, and sigalt stack are located wherever mmap finds room for them.

Currently only implemented for Darwin, but should work for linux and
solaris.  We enable this by default on Darwin now.
---
 src/lisp/Config.x86_darwin     | 2 +-
 src/lisp/x86-validate-darwin.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/lisp/Config.x86_darwin b/src/lisp/Config.x86_darwin
index 03324aac9..c21e746c7 100644
--- a/src/lisp/Config.x86_darwin
+++ b/src/lisp/Config.x86_darwin
@@ -6,7 +6,7 @@ include Config.x86_common
 # you have the 10.5 SDK available.
 MIN_VER = -mmacosx-version-min=10.5
 
-CPPFLAGS += -DDARWIN $(MIN_VER) -m32
+CPPFLAGS += -DDARWIN $(MIN_VER) -m32 -DRELOCATABLE_STACK_START
 CFLAGS += -g3 -mtune=generic
 ASFLAGS += -g3 $(MIN_VER)
 
diff --git a/src/lisp/x86-validate-darwin.h b/src/lisp/x86-validate-darwin.h
index 09f139628..1ac37f3d0 100644
--- a/src/lisp/x86-validate-darwin.h
+++ b/src/lisp/x86-validate-darwin.h
@@ -18,12 +18,12 @@
 #define STATIC_SPACE_START	(SpaceStart_TargetStatic)
 #define STATIC_SPACE_SIZE	(0x0ffff000)	/* 256MB - 1 page */
 
-#if 0
+#ifndef RELOCATABLE_STACK_START
 #define BINDING_STACK_START	(0x38000000)
 #endif
 #define BINDING_STACK_SIZE	(0x07fff000)	/* 128MB - 1 page */
 
-#if 0
+#ifdef RELOCATABLE_STACK_START
 #define CONTROL_STACK_START	(0x40000000)
 #endif
 
@@ -33,7 +33,7 @@
  */
 #define CONTROL_STACK_SIZE	(0x07fdf000)	/* 128MB - SIGSTKSZ - 1 page */
 
-#if 0
+#ifndef RELOCATABLE_STACK_START
 #define SIGNAL_STACK_START	(0x47fe0000)    /* One page past the end of the control stack */
 #endif
 #define SIGNAL_STACK_SIZE	SIGSTKSZ
-- 
GitLab