-;;; FIXME: Couldn't/shouldn't these be DEFCONSTANT instead of DEFPARAMETER?
-#!-linux (defparameter *target-read-only-space-start* #x10000000)
-#!-linux (defparameter *target-static-space-start*
- ;; FIXME: was #x28000000 until RAW's RUN-PROGRAM
- ;; patches, why the change?
- #x30000000)
-#!-linux (defparameter *target-dynamic-space-start* #x48000000)
-#!+linux (defparameter *target-read-only-space-start* #x01000000)
-#!+linux (defparameter *target-static-space-start* #x05000000)
-#!+linux (defparameter *target-dynamic-space-start* #x09000000)
+;;; Note: Mostly these values are black magic, inherited from CMU CL
+;;; without any documentation. However, there were a few explanatory
+;;; comments in the CMU CL sources:
+;;; * On Linux,
+;;; ** The space 0x08000000-0x10000000 is "C program and memory allocation".
+;;; ** The space 0x40000000-0x48000000 is reserved for shared libs.
+;;; ** The space >0xE0000000 is "C stack - Alien stack".
+;;; * On FreeBSD,
+;;; ** The space 0x0E000000-0x10000000 is "Foreign segment".
+;;; ** The space 0x20000000-0x30000000 is reserved for shared libs.
+;;; And there have been a few changes since the fork:
+;;; * The FreeBSD STATIC-SPACE-START value was bumped up from
+;;; #x28000000 to #x30000000 when FreeBSD ld.so dynamic linking
+;;; support was added for FreeBSD ca. 20000910. This was to keep from
+;;; stomping on an address range that the dynamic libraries want to use.
+;;; (They want to use this address range even if we try to reserve it
+;;; with a call to validate() as the first operation in main().)
+
+#!+linux
+(progn
+
+ (defconstant read-only-space-start #x01000000)
+ (defconstant read-only-space-end #x037ff000)
+
+ (defconstant static-space-start #x05000000)
+ (defconstant static-space-end #x07fff000)
+
+ (defconstant dynamic-space-start #x09000000)
+ (defconstant dynamic-space-end #x29000000)
+
+ (defconstant control-stack-start #x50000000)
+ (defconstant control-stack-end #x57fff000)
+
+ (defconstant binding-stack-start #x60000000)
+ (defconstant binding-stack-end #x67fff000))
+
+#!+bsd
+(progn
+
+ (defconstant read-only-space-start #x10000000)
+ (defconstant read-only-space-end #x1ffff000)
+
+ (defconstant static-space-start
+ #!+freebsd #x30000000
+ #!+openbsd #x28000000)
+ (defconstant static-space-end #x37fff000)
+
+ (defconstant binding-stack-start #x38000000)
+ (defconstant binding-stack-end #x3ffff000)
+
+ (defconstant control-stack-start #x40000000)
+ (defconstant control-stack-end #x47fff000)
+
+ (defconstant dynamic-space-start #x48000000)
+ (defconstant dynamic-space-end #x88000000))