Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

23 changed files:

Changes:

  • src/lisp/Config.sparc_sunc
    --- a/src/lisp/Config.sparc_sunc
    +++ b/src/lisp/Config.sparc_sunc
    @@ -24,7 +24,7 @@ CC_V8PLUS = -m32 -xarch=sparc
     AS_V8PLUS = -m32 -xarch=sparc
     endif
     
    -CFLAGS += -xlibmieee -O
    +CFLAGS += -xlibmieee -O -DRELOCATABLE_STACK_START
     DEPEND_FLAGS = -xM
     ASFLAGS = $(AS_V8PLUS)
     OS_LINK_FLAGS = -M /usr/lib/ld/map.noexstk
    

  • src/lisp/Config.x86_common
    --- a/src/lisp/Config.x86_common
    +++ b/src/lisp/Config.x86_common
    @@ -43,7 +43,8 @@ CPP_INCLUDE_OPTIONS := -I. -I$(PATH1) -I-
     endif
     
     CPPFLAGS := $(CPP_DEFINE_OPTIONS) $(CPP_INCLUDE_OPTIONS) 
    -CFLAGS += -Wstrict-prototypes -Wall -O2 -g -fno-omit-frame-pointer
    +CFLAGS += -Wstrict-prototypes -Wall -g -fno-omit-frame-pointer
    +CFLAGS += -O2
     ASFLAGS = -g 
     
     ASSEM_SRC = x86-assem.S
    

  • src/lisp/Config.x86_darwin
    --- 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)
     
    

  • src/lisp/Config.x86_linux
    --- a/src/lisp/Config.x86_linux
    +++ b/src/lisp/Config.x86_linux
    @@ -1,7 +1,7 @@
     # -*- Mode: makefile -*-
     include Config.x86_common
     
    -CPPFLAGS += -m32 -D__NO_CTYPE -D_GNU_SOURCE
    +CPPFLAGS += -m32 -D__NO_CTYPE -D_GNU_SOURCE -DRELOCATABLE_STACK_START
     CFLAGS += -rdynamic  -march=pentium4 -mfpmath=sse -mtune=generic
     
     UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
    

  • src/lisp/Darwin-os.c
    --- a/src/lisp/Darwin-os.c
    +++ b/src/lisp/Darwin-os.c
    @@ -464,8 +464,8 @@ valid_addr(os_vm_address_t addr)
     #ifndef GENCGC
     	|| in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size)
     #endif
    -	|| in_range_p(addr, CONTROL_STACK_START, control_stack_size)
    -	|| in_range_p(addr, BINDING_STACK_START, binding_stack_size))
    +	|| in_range_p(addr, (lispobj)control_stack, control_stack_size)
    +	|| in_range_p(addr, (lispobj)binding_stack, binding_stack_size))
     	return TRUE;
         return FALSE;
     }
    

  • src/lisp/FreeBSD-os.c
    --- a/src/lisp/FreeBSD-os.c
    +++ b/src/lisp/FreeBSD-os.c
    @@ -224,8 +224,8 @@ valid_addr(os_vm_address_t addr)
     #ifndef GENCGC
     	|| in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size)
     #endif
    -	|| in_range_p(addr, CONTROL_STACK_START, control_stack_size)
    -	|| in_range_p(addr, BINDING_STACK_START, binding_stack_size))
    +	|| in_range_p(addr, control_stack, control_stack_size)
    +	|| in_range_p(addr, binding_stack, binding_stack_size))
     	return TRUE;
         return FALSE;
     }
    

  • src/lisp/Linux-os.c
    --- a/src/lisp/Linux-os.c
    +++ b/src/lisp/Linux-os.c
    @@ -385,8 +385,8 @@ valid_addr(os_vm_address_t addr)
     	|| in_range_p(addr, STATIC_SPACE_START, static_space_size)
     	|| in_range_p(addr, DYNAMIC_0_SPACE_START, dynamic_space_size)
     	|| in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size)
    -	|| in_range_p(addr, CONTROL_STACK_START, control_stack_size)
    -	|| in_range_p(addr, BINDING_STACK_START, binding_stack_size))
    +	|| in_range_p(addr, control_stack, control_stack_size)
    +	|| in_range_p(addr, binding_stack, binding_stack_size))
     	return TRUE;
         return FALSE;
     }
    @@ -454,17 +454,17 @@ sigsegv_handler(HANDLER_ARGS)
     #ifdef i386
         interrupt_handle_now(signal, contextstruct);
     #else
    -#define CONTROL_STACK_TOP (((char*) CONTROL_STACK_START) + control_stack_size)
    +#define CONTROL_STACK_TOP (((char*) control_stack) + control_stack_size)
     
         addr = arch_get_bad_addr(signal, code, context);
     
         if (addr != NULL && context->sc_regs[reg_ALLOC] & (1 << 63)) {
     	context->sc_regs[reg_ALLOC] -= (1 << 63);
     	interrupt_handle_pending(context);
    -    } else if (addr > CONTROL_STACK_TOP && addr < BINDING_STACK_START) {
    +    } else if (addr > CONTROL_STACK_TOP && addr < (os_vm_address_t)binding_stack) {
     	fprintf(stderr, "Possible stack overflow at 0x%08lX!\n", addr);
     	/* try to fix control frame pointer */
    -	while (!(CONTROL_STACK_START <= *current_control_frame_pointer &&
    +	while (!((lispobj)control_stack <= *current_control_frame_pointer &&
     		 *current_control_frame_pointer <= CONTROL_STACK_TOP))
     	    ((char *) current_control_frame_pointer) -= sizeof(lispobj);
     	ldb_monitor();
    

  • src/lisp/NetBSD-os.c
    --- a/src/lisp/NetBSD-os.c
    +++ b/src/lisp/NetBSD-os.c
    @@ -277,8 +277,8 @@ valid_addr(os_vm_address_t addr)
     #ifndef GENCGC
     	|| in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size)
     #endif
    -	|| in_range_p(addr, CONTROL_STACK_START, control_stack_size)
    -	|| in_range_p(addr, BINDING_STACK_START, binding_stack_size))
    +	|| in_range_p(addr, control_stack, control_stack_size)
    +	|| in_range_p(addr, binding_stack, binding_stack_size))
     	return TRUE;
         return FALSE;
     }
    

  • src/lisp/backtrace.c
    --- a/src/lisp/backtrace.c
    +++ b/src/lisp/backtrace.c
    @@ -252,7 +252,7 @@ backtrace(int nframes)
     static int
     stack_pointer_p(unsigned long p)
     {
    -    return (p < CONTROL_STACK_START + control_stack_size
    +    return ((void *)p < (void *)control_stack + control_stack_size
     	    && p > (unsigned long) &p && (p & 3) == 0);
     }
     
    

  • src/lisp/gencgc.c
    --- a/src/lisp/gencgc.c
    +++ b/src/lisp/gencgc.c
    @@ -166,7 +166,7 @@ check_escaped_stack_object(lispobj * where, lispobj obj)
     
         if (Pointerp(obj)
     	&& (p = (void *) PTR(obj),
    -	    (p >= (void *) CONTROL_STACK_START
    +	    (p >= (void *) control_stack
     	     && p < (void *) control_stack_end))) {
     	char *space;
     
    @@ -195,7 +195,7 @@ check_escaped_stack_object(lispobj * where, lispobj obj)
     	    lose("Escaped stack-allocated object 0x%08lx at %p in %s\n",
     		 (unsigned long) obj, where, space);
     #ifndef i386
    -	else if ((where >= (lispobj *) CONTROL_STACK_START
    +	else if ((where >= (lispobj *) control_stack
     		  && where < (lispobj *) (control_stack_end))
     		 || (space == NULL)) {
     	    /* Do nothing if it the reference is from the control stack,
    @@ -2136,17 +2136,19 @@ read_only_space_p(lispobj obj)
     static inline boolean
     control_stack_space_p(lispobj obj)
     {
    -    lispobj end = CONTROL_STACK_START + control_stack_size;
    +    char *object = (char *) obj;
    +    char *end = (char *)control_stack + control_stack_size;
     
    -    return (obj >= CONTROL_STACK_START) && (obj < end);
    +    return (object >= (char *) control_stack) && (object < end);
     }
     
     static inline boolean
     binding_stack_space_p(lispobj obj)
     {
    -    lispobj end = BINDING_STACK_START + binding_stack_size;
    +    char *object = (char *) obj;
    +    char *end = (char *)binding_stack + binding_stack_size;
     
    -    return (obj >= BINDING_STACK_START) && (obj < end);
    +    return (object >= (char *) binding_stack) && (object < end);
     }
         
     static inline boolean
    @@ -2157,7 +2159,12 @@ signal_space_p(lispobj obj)
     
         return (obj >= SIGNAL_STACK_START) && (obj < end);
     #else
    -    return FALSE;
    +    extern char altstack[];
    +    
    +    char* object = (char*) obj;
    +    char* end = altstack + SIGNAL_STACK_SIZE;
    +    
    +    return (object >= altstack && object < end);
     #endif    
     }
     
    @@ -7322,11 +7329,11 @@ verify_gc(void)
         int static_space_size = (lispobj *) SymbolValue(STATIC_SPACE_FREE_POINTER)
     	- (lispobj *) static_space;
         int binding_stack_size = (lispobj *) get_binding_stack_pointer()
    -	- (lispobj *) BINDING_STACK_START;
    +	- (lispobj *) binding_stack;
     
         verify_space((lispobj *) READ_ONLY_SPACE_START, read_only_space_size);
         verify_space((lispobj *) static_space, static_space_size);
    -    verify_space((lispobj *) BINDING_STACK_START, binding_stack_size);
    +    verify_space((lispobj *) binding_stack, binding_stack_size);
         verify_space((lispobj *) (void *) &scavenger_hooks, 1);
     }
     
    @@ -7494,16 +7501,16 @@ scavenge_interrupt_handlers(void)
     static void
     scavenge_control_stack(void)
     {
    -    unsigned long control_stack_size;
    +    unsigned long current_stack_size;
     
    -    control_stack_size = current_control_stack_pointer - control_stack;
    +    current_stack_size = current_control_stack_pointer - control_stack;
     
     #ifdef PRINTNOISE
         printf("Scavenging the control stack (%d bytes) ...\n",
    -	   control_stack_size * sizeof(lispobj));
    +	   current_stack_size * sizeof(lispobj));
     #endif
     
    -    scavenge(control_stack, control_stack_size);
    +    scavenge(control_stack, current_stack_size);
     
     #ifdef PRINTNOISE
         printf("Done scavenging the control stack.\n");
    @@ -7523,7 +7530,7 @@ garbage_collect_generation(int generation, int raise)
     
     #ifdef GC_ASSERTIONS
     #if defined(i386) || defined(__x86_64)
    -    invalid_stack_start = (void *) CONTROL_STACK_START;
    +    invalid_stack_start = (void *) control_stack;
         invalid_stack_end = (void *) &raise;
     #else /* not i386 */
         invalid_stack_start = (void *) &raise;
    

  • src/lisp/globals.c
    --- a/src/lisp/globals.c
    +++ b/src/lisp/globals.c
    @@ -28,7 +28,6 @@ lispobj *dynamic_1_space;
     unsigned dynamic_space_size;
     lispobj *control_stack;
     
    -
     #if (defined(i386) || defined(__x86_64))
     lispobj *control_stack_end;
     #endif
    

  • src/lisp/interrupt.c
    --- a/src/lisp/interrupt.c
    +++ b/src/lisp/interrupt.c
    @@ -405,10 +405,7 @@ interrupt_maybe_gc(HANDLER_ARGS)
     * Noise to install handlers.                                     *
     \****************************************************************/
     
    -#if !(defined(i386) || defined(__x86_64))
    -#define SIGNAL_STACK_SIZE SIGSTKSZ
    -static char altstack[SIGNAL_STACK_SIZE];
    -#endif
    +char altstack[SIGNAL_STACK_SIZE];
     
     void
     interrupt_install_low_level_handler(int signal, void handler(HANDLER_ARGS))
    @@ -431,7 +428,7 @@ interrupt_install_low_level_handler(int signal, void handler(HANDLER_ARGS))
         if (signal == PROTECTION_VIOLATION_SIGNAL) {
     	stack_t sigstack;
     
    -#if (defined( i386 ) || defined(__x86_64))
    +#if defined(SIGNAL_STACK_START)
     	sigstack.ss_sp = (void *) SIGNAL_STACK_START;
     #else
     	sigstack.ss_sp = (void *) altstack;
    

  • src/lisp/lisp.c
    --- a/src/lisp/lisp.c
    +++ b/src/lisp/lisp.c
    @@ -687,8 +687,16 @@ main(int argc, const char *argv[], const char *envp[])
         if (builtin_image_flag != 0)
     	map_core_sections(argv[0]);
     #endif
    +
    +    /*
    +     * Validate the basic lisp spaces first like the heap and static
    +     * and read-only spaces.  Do this so that the stacks (if thy're
    +     * relocatable) don't get randomly allocated on top of our desired
    +     * lisp spaces.
    +     */
         validate();
         gc_init();
    +    validate_stacks();
     
         /* This is the first use of malloc() and must come after the
          * static memory layout is mmapped to avoid conflicts with possible
    

  • src/lisp/os-common.c
    --- a/src/lisp/os-common.c
    +++ b/src/lisp/os-common.c
    @@ -413,7 +413,7 @@ guard_zones(char **yellow_start, char **red_start)
         /*
          * All x86's have a control stack (aka C stack) that grows down.
          */
    -    char *end = (char *) CONTROL_STACK_START;
    +    char *end = (char *) control_stack;
     
         *red_start = end;
         *yellow_start = *red_start + RED_ZONE_SIZE;
    @@ -424,7 +424,7 @@ guard_zones(char **yellow_start, char **red_start)
          * control stack area.
          */
     
    -    char *end = (char *) CONTROL_STACK_START + control_stack_size;
    +    char *end = (char *) control_stack + control_stack_size;
     
         *red_start = end - RED_ZONE_SIZE;
         *yellow_start = *red_start - YELLOW_ZONE_SIZE;
    

  • src/lisp/ppc-validate.h
    --- a/src/lisp/ppc-validate.h
    +++ b/src/lisp/ppc-validate.h
    @@ -45,6 +45,8 @@
     #define CONTROL_STACK_SIZE  	(0x07ff8000)	/* 128 MB, almost */
     #define CONTROL_STACK_END       (CONTROL_STACK_START + control_stack_size)
     
    +#define SIGNAL_STACK_SIZE	SIGSTKSZ
    +
     #define BINDING_STACK_START 	(0x38000000)
     #define BINDING_STACK_SIZE  	(0x07ff8000)	/* 128 MB, almost */
     
    

  • src/lisp/save.c
    --- a/src/lisp/save.c
    +++ b/src/lisp/save.c
    @@ -136,7 +136,9 @@ save(char *filename, lispobj init_function, int sse2_mode)
         }
         printf("[Undoing binding stack... ");
         fflush(stdout);
    -    unbind_to_here((lispobj *) BINDING_STACK_START);
    +
    +    unbind_to_here((lispobj *) binding_stack);
    +
         SetSymbolValue(CURRENT_CATCH_BLOCK, 0);
         SetSymbolValue(CURRENT_UNWIND_PROTECT_BLOCK, 0);
         SetSymbolValue(EVAL_STACK_TOP, 0);
    @@ -278,7 +280,9 @@ save_executable(char *filename, lispobj init_function)
     
         printf("[Undoing binding stack... ");
         fflush(stdout);
    -    unbind_to_here((lispobj *)BINDING_STACK_START);
    +
    +    unbind_to_here((lispobj *)binding_stack);
    +
         SetSymbolValue(CURRENT_CATCH_BLOCK, 0);
         SetSymbolValue(CURRENT_UNWIND_PROTECT_BLOCK, 0);
         SetSymbolValue(EVAL_STACK_TOP, 0);
    

  • src/lisp/solaris-os.c
    --- a/src/lisp/solaris-os.c
    +++ b/src/lisp/solaris-os.c
    @@ -169,8 +169,14 @@ os_flush_icache(os_vm_address_t address, os_vm_size_t length)
     void
     os_protect(os_vm_address_t address, os_vm_size_t length, os_vm_prot_t prot)
     {
    -    if (mprotect((void *) address, length, prot) == -1)
    -	perror("mprotect");
    +    if (mprotect((void *) address, length, prot) == -1) {
    +        char msg[1000];
    +
    +        snprintf(msg, sizeof(msg), "mprotect: os_protect(0x%p, %u, 0x%x): ",
    +                 address, length, prot);
    +        
    +	perror(msg);
    +    }
     }
     
     static boolean
    @@ -193,8 +199,8 @@ boolean valid_addr(os_vm_address_t addr)
     #ifndef GENCGC
     	    || in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size)
     #endif
    -	    || in_range_p(addr, CONTROL_STACK_START, control_stack_size)
    -	    || in_range_p(addr, BINDING_STACK_START, binding_stack_size));
    +	    || in_range_p(addr, (lispobj)control_stack, control_stack_size)
    +	    || in_range_p(addr, (lispobj)binding_stack, binding_stack_size));
     }
     
     /* ---------------------------------------------------------------- */
    @@ -403,11 +409,16 @@ os_vm_address_t round_up_sparse_size(os_vm_address_t addr)
     /*
      * An array of the start of the spaces which should have holes placed
      * after them.  Must not include the dynamic spaces because the size
    - * of the dynamic space can be controlled from the command line.
    + * of the dynamic space can be controlled from the command line.  Also
    + * must not include the binding and control stacks.  They're handled
    + * below.
      */
     static os_vm_address_t spaces[] = {
         READ_ONLY_SPACE_START, STATIC_SPACE_START,
    -    BINDING_STACK_START, CONTROL_STACK_START
    +#ifndef RELOCATABLE_STACK_START
    +    BINDING_STACK_START,
    +    CONTROL_STACK_START
    +#endif    
     };
     
     /*
    @@ -430,27 +441,41 @@ static unsigned long *space_size[] = {
     #define HOLE_SIZE 0x2000
     
     void
    -make_holes(void)
    +make_hole(os_vm_address_t space_start, size_t space_size)
     {
    -    int k;
         os_vm_address_t hole;
     
         /* Make holes of the appropriate size for desired spaces */
     
    -    for (k = 0; k < sizeof(spaces) / sizeof(spaces[0]); ++k) {
    -
    -	hole = spaces[k] + *space_size[k];
    +    hole = space_start + space_size;
     
    -	if (os_validate(hole, HOLE_SIZE) == NULL) {
    -	    fprintf(stderr,
    -		    "ensure_space: Failed to validate hole of %d bytes at 0x%08lX\n",
    -		    HOLE_SIZE, (unsigned long) hole);
    -	    exit(1);
    -	}
    -	/* Make it inaccessible */
    -	os_protect(hole, HOLE_SIZE, 0);
    +    if (os_validate(hole, HOLE_SIZE) == NULL) {
    +        fprintf(stderr,
    +                "ensure_space: Failed to validate hole of %d bytes at 0x%08lX\n",
    +                HOLE_SIZE, (unsigned long) hole);
    +        exit(1);
         }
    +    /* Make it inaccessible */
    +    os_protect(hole, HOLE_SIZE, 0);
    +}
    +
    +void
    +make_holes(void)
    +{
    +    int k;
    +    os_vm_address_t hole;
    +
    +    /*
    +     * Make holes of the appropriate size for desired spaces.  The
    +     * stacks are handled in make_stack_holes, if they are
    +     * relocatable.
    +     */
     
    +    for (k = 0; k < sizeof(spaces) / sizeof(spaces[0]); ++k) {
    +        make_hole(spaces[k], *space_size[k]);
    +    }
    +    
    +    
         /* Round up the dynamic_space_size to the nearest SPARSE_BLOCK_SIZE */
         dynamic_space_size = round_up_sparse_size(dynamic_space_size);
     
    @@ -477,6 +502,15 @@ make_holes(void)
     #endif
     }
     
    +void
    +make_stack_holes(void)
    +{
    +#ifdef RELOCATABLE_STACK_START
    +    make_hole((os_vm_address_t)control_stack, control_stack_size);
    +    make_hole((os_vm_address_t)binding_stack, binding_stack_size);
    +#endif
    +}
    +    
     void *
     os_dlsym(const char *sym_name, lispobj lib_list)
     {
    

  • src/lisp/sparc-validate.h
    --- a/src/lisp/sparc-validate.h
    +++ b/src/lisp/sparc-validate.h
    @@ -92,15 +92,24 @@
     #define READ_ONLY_SPACE_START	(SpaceStart_TargetReadOnly)
     #define READ_ONLY_SPACE_SIZE	((2*MB_128) - SPARSE_BLOCK_SIZE)	/* 256 MB - 32 KB, 256 MB max */
     
    +#ifndef RELOCATABLE_STACK_START
     #define BINDING_STACK_START 	(0x20000000)
    +#endif
    +
     #define BINDING_STACK_SIZE  	(MB_128 - SPARSE_BLOCK_SIZE)	/* 128 MB - 32 KB, 128 MB max */
     
     #define STATIC_SPACE_START  	(SpaceStart_TargetStatic)
     #define STATIC_SPACE_SIZE   	((2*MB_128) - SPARSE_BLOCK_SIZE)	/* 256 MB - 32 KB, 256 MB max */
     
    +#ifndef RELOCATABLE_STACK_START
     #define CONTROL_STACK_START 	(0x38000000)
    +#endif
     #define CONTROL_STACK_SIZE  	(MB_128 - SPARSE_BLOCK_SIZE)	/* 128 MB - 32 KB, 128 MB max */
    +#if 0
     #define CONTROL_STACK_END       (CONTROL_STACK_START + control_stack_size)
    +#endif
    +
    +#define SIGNAL_STACK_SIZE	SIGSTKSZ
     
     #define DYNAMIC_0_SPACE_START	(SpaceStart_TargetDynamic)
     
    

  • src/lisp/validate.c
    --- a/src/lisp/validate.c
    +++ b/src/lisp/validate.c
    @@ -18,6 +18,7 @@
     
     #ifdef sparc
     extern void make_holes(void);
    +extern void make_stack_holes(void);
     #endif
     
     static void
    @@ -92,20 +93,10 @@ validate(void)
         */
     #endif
     
    -    /* Control Stack */
    -    control_stack = (lispobj *) CONTROL_STACK_START;
    -#if (defined(i386) || defined(__x86_64))
    -    control_stack_end = (lispobj *) (CONTROL_STACK_START + control_stack_size);
    -#endif
    -    ensure_space(control_stack, control_stack_size);
    -
     #ifdef SIGNAL_STACK_START
         ensure_space((lispobj *) SIGNAL_STACK_START, SIGNAL_STACK_SIZE);
     #endif
     
    -    /* Binding Stack */
    -    binding_stack = (lispobj *) BINDING_STACK_START;
    -    ensure_space(binding_stack, binding_stack_size);
     #ifdef LINKAGE_TABLE
         ensure_space((lispobj *) FOREIGN_LINKAGE_SPACE_START,
     		 FOREIGN_LINKAGE_SPACE_SIZE);
    @@ -118,6 +109,40 @@ validate(void)
         printf(" done.\n");
     #endif
     
    +}
    +
    +void
    +validate_stacks()
    +{
    +    /* Control Stack */
    +#ifdef CONTROL_STACK_START
    +    /* Map the control stack at a fixed location */
    +    control_stack = (lispobj *) CONTROL_STACK_START;
    +#if (defined(i386) || defined(__x86_64))
    +    control_stack_end = (lispobj *) (CONTROL_STACK_START + control_stack_size);
    +#endif
    +    ensure_space(control_stack, control_stack_size);
    +#else
    +    /* Map the conrol stack wherever we have space */
    +    control_stack = (lispobj*) os_validate(NULL, control_stack_size);
    +
    +#if (defined(i386) || defined(__x86_64))
    +    control_stack_end = (void*)control_stack + control_stack_size;
    +#endif
    +#endif
    +
    +    /* Binding Stack */
    +#ifdef BINDING_STACK_START
    +    binding_stack = (lispobj *) BINDING_STACK_START;
    +    ensure_space(binding_stack, binding_stack_size);
    +#else
    +    /* Map the binding stack wherever we have space */
    +    binding_stack = (lispobj*) os_validate(NULL, binding_stack_size);
    +#endif
    +#ifdef sparc
    +    make_stack_holes();
    +#endif
    +
     #ifdef RED_ZONE_HIT
         os_guard_control_stack(0, 1);
     #endif
    

  • src/lisp/validate.h
    --- a/src/lisp/validate.h
    +++ b/src/lisp/validate.h
    @@ -37,5 +37,6 @@
     #endif
     
     extern void validate(void);
    +extern void validate_stacks(void);
     
     #endif /* _VALIDATE_H_ */
    

  • src/lisp/x86-assem.S
    --- a/src/lisp/x86-assem.S
    +++ b/src/lisp/x86-assem.S
    @@ -143,7 +143,8 @@ FUNCDEF(call_into_lisp)
     	movl	%eax, GNAME(foreign_function_call_active)
     
     	movl	%esp,%ebx	# remember current stack
    -	cmpl	$CONTROL_STACK_START,%esp
    +	cmpl	GNAME(control_stack), %esp
    +
     	jbe	ChangeToLispStack
     	cmpl	GNAME(control_stack_end), %esp
     	jbe	OnLispStack
    

  • src/lisp/x86-validate-darwin.h
    --- a/src/lisp/x86-validate-darwin.h
    +++ b/src/lisp/x86-validate-darwin.h
    @@ -18,10 +18,14 @@
     #define STATIC_SPACE_START	(SpaceStart_TargetStatic)
     #define STATIC_SPACE_SIZE	(0x0ffff000)	/* 256MB - 1 page */
     
    +#ifndef RELOCATABLE_STACK_START
     #define BINDING_STACK_START	(0x38000000)
    +#endif
     #define BINDING_STACK_SIZE	(0x07fff000)	/* 128MB - 1 page */
     
    +#ifdef RELOCATABLE_STACK_START
     #define CONTROL_STACK_START	(0x40000000)
    +#endif
     
     /*
      * According to /usr/include/sys/signal.h, MINSIGSTKSZ is 32K and
    @@ -29,7 +33,9 @@
      */
     #define CONTROL_STACK_SIZE	(0x07fdf000)	/* 128MB - SIGSTKSZ - 1 page */
     
    +#ifndef RELOCATABLE_STACK_START
     #define SIGNAL_STACK_START	(0x47fe0000)    /* One page past the end of the control stack */
    +#endif
     #define SIGNAL_STACK_SIZE	SIGSTKSZ
     
     #define DYNAMIC_0_SPACE_START	(SpaceStart_TargetDynamic)
    

  • src/lisp/x86-validate-linux.h
    --- a/src/lisp/x86-validate-linux.h
    +++ b/src/lisp/x86-validate-linux.h
    @@ -45,13 +45,19 @@
     #define STATIC_SPACE_START	(SpaceStart_TargetStatic)
     #define STATIC_SPACE_SIZE	(0x0ffff000)	/* 256MB - 1 page */
     
    +#ifndef RELOCATABLE_STACK_START
     #define BINDING_STACK_START	(0x20000000)
    +#endif
     #define BINDING_STACK_SIZE	(0x07fff000)	/* 128MB - 1 page */
     
    +#ifndef RELOCATABLE_STACK_START
     #define CONTROL_STACK_START	0x38000000
    +#endif
     #define CONTROL_STACK_SIZE	(0x07fff000 - 8192)
     
    +#ifndef RELOCATABLE_STACK_START
     #define SIGNAL_STACK_START	CONTROL_STACK_END
    +#endif
     #define SIGNAL_STACK_SIZE	SIGSTKSZ
     
     #define DYNAMIC_0_SPACE_START	(SpaceStart_TargetDynamic)