Blob Blame History Raw
diff -dur gcl-2.6.8.ORIG/configure gcl-2.6.8/configure
--- gcl-2.6.8.ORIG/configure	2010-03-23 11:21:56.155975563 -0600
+++ gcl-2.6.8/configure	2010-03-23 11:22:09.803019259 -0600
@@ -8749,9 +8749,11 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
+		    #define CAN_UNRANDOMIZE_SBRK 1
+		    #include "h/unrandomize.h"
 		    void gprof_cleanup() {}
 		    int main(int argc,char *argv[],char *envp[]) {
-	            #include "h/unrandomize.h"
+	            UNRANDOMIZE_SBRK;
 		    return 0;}
 _ACEOF
 rm -f conftest$ac_exeext
@@ -8816,12 +8818,11 @@
 /* end confdefs.h.  */
 
 		    #include <stdio.h>
+		    #include "h/unrandomize.h"
 	            void gprof_cleanup() {}
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
-			#ifdef CAN_UNRANDOMIZE_SBRK
-			#include "h/unrandomize.h"
-			#endif
+			UNRANDOMIZE_SBRK;
 			if (!(f=fopen("conftest1","w"))) return -1;
 			fprintf(f,"%u",sbrk(0));
 			return 0;}
@@ -8878,12 +8879,11 @@
 /* end confdefs.h.  */
 
 		    #include <stdio.h>
+		    #include "h/unrandomize.h"
                     void gprof_cleanup() {}
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
-			#ifdef CAN_UNRANDOMIZE_SBRK
-			#include "h/unrandomize.h"
-			#endif
+			UNRANDOMIZE_SBRK;
 			if (!(f=fopen("conftest1","w"))) return -1;
 			fprintf(f,"%u",sbrk(0));
 			return 0;}
@@ -9034,6 +9034,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "h/unrandomize.h"
 
 void gprof_cleanup() {}
 int
@@ -9042,9 +9043,7 @@
   char *b,*b1;
   FILE *fp;
 
-#ifdef CAN_UNRANDOMIZE_SBRK
-#include "h/unrandomize.h"
-#endif
+  UNRANDOMIZE_SBRK;
   b = (void *) malloc(1000);
   fp = fopen("conftest1","w");
 
diff -dur gcl-2.6.8.ORIG/configure.in gcl-2.6.8/configure.in
--- gcl-2.6.8.ORIG/configure.in	2010-03-23 11:21:56.157974544 -0600
+++ gcl-2.6.8/configure.in	2010-03-23 11:22:09.804016306 -0600
@@ -1152,9 +1152,11 @@
 
 	AC_MSG_CHECKING([for personality(ADDR_NO_RANDOMIZE) support])
 	AC_RUN_IFELSE([AC_LANG_SOURCE([[
+		    #define CAN_UNRANDOMIZE_SBRK 1
+		    #include "h/unrandomize.h"
 		    void gprof_cleanup() {}
 		    int main(int argc,char *argv[],char *envp[]) {
-	            #include "h/unrandomize.h"
+	            UNRANDOMIZE_SBRK;
 		    return 0;}]])],CAN_UNRANDOMIZE_SBRK=1,CAN_UNRANDOMIZE_SBRK=0,CAN_UNRANDOMIZE_SBRK=0)
 
 	if test "$CAN_UNRANDOMIZE_SBRK" != 0 ; then
@@ -1167,12 +1169,11 @@
 	AC_MSG_CHECKING([that sbrk is (now) non-random])
 	AC_RUN_IFELSE([AC_LANG_SOURCE([[
 		    #include <stdio.h>
+		    #include "h/unrandomize.h"
 	            void gprof_cleanup() {}
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
-			#ifdef CAN_UNRANDOMIZE_SBRK
-			#include "h/unrandomize.h"
-			#endif
+			UNRANDOMIZE_SBRK;
 			if (!(f=fopen("conftest1","w"))) return -1;
 			fprintf(f,"%u",sbrk(0));
 			return 0;}]])],SBRK=`cat conftest1`,SBRK=0,SBRK=0)
@@ -1181,12 +1182,11 @@
 	fi
 	AC_RUN_IFELSE([AC_LANG_SOURCE([[
 		    #include <stdio.h>
+		    #include "h/unrandomize.h"
                     void gprof_cleanup() {}
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
-			#ifdef CAN_UNRANDOMIZE_SBRK
-			#include "h/unrandomize.h"
-			#endif
+			UNRANDOMIZE_SBRK;
 			if (!(f=fopen("conftest1","w"))) return -1;
 			fprintf(f,"%u",sbrk(0));
 			return 0;}]])],SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0)
@@ -1228,6 +1228,7 @@
 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <stdlib.h>
+#include "h/unrandomize.h"
 
 void gprof_cleanup() {}
 int
@@ -1236,9 +1237,7 @@
   char *b,*b1;
   FILE *fp;
 
-#ifdef CAN_UNRANDOMIZE_SBRK
-#include "h/unrandomize.h"
-#endif
+  UNRANDOMIZE_SBRK;
   b = (void *) malloc(1000);
   fp = fopen("conftest1","w");
 
diff -dur gcl-2.6.8.ORIG/h/unrandomize.h gcl-2.6.8/h/unrandomize.h
--- gcl-2.6.8.ORIG/h/unrandomize.h	2010-01-12 07:19:15.000000000 -0700
+++ gcl-2.6.8/h/unrandomize.h	2010-03-23 11:22:41.350120555 -0600
@@ -1,39 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/personality.h>
 #include <syscall.h>
 #include <unistd.h>
 #include <alloca.h>
 #include <errno.h>
 
-
-{
-  errno=0;
-
-  {
-
-    long pers = personality(0xffffffffUL);
-    if (pers==-1) {printf("personality failure %d\n",errno);exit(-1);}
-    if (!(pers & ADDR_NO_RANDOMIZE) && !getenv("GCL_UNRANDOMIZE")) {
-      errno=0;
-      if (personality(pers | ADDR_NO_RANDOMIZE) != -1 && personality(0xffffffffUL) & ADDR_NO_RANDOMIZE) {
-	int i;
-	char **n;
-	for (i=0;envp[i];i++);
-	n=alloca((i+2)*sizeof(*n));
-	n[i+1]=0;
-	n[i--]="GCL_UNRANDOMIZE=t";
-	for (;i>=0;i--)
-	  n[i]=envp[i];
-#ifdef GCL_GPROF
-	gprof_cleanup();
+#ifdef CAN_UNRANDOMIZE_SBRK
+# ifdef GCL_GPROF
+#  define GPROF_CLEANUP gprof_cleanup()
+# else
+#  define GPROF_CLEANUP
+# endif
+# define UNRANDOMIZE_SBRK do {						\
+    errno=0;								\
+    {									\
+      long pers = personality(0xffffffffUL);				\
+      if (pers==-1) {printf("personality failure %d\n",errno);exit(-1);} \
+      if (!(pers & ADDR_NO_RANDOMIZE) && !getenv("GCL_UNRANDOMIZE")) {	\
+	errno=0;							\
+	if (personality(pers | ADDR_NO_RANDOMIZE) != -1 && personality(0xffffffffUL) & ADDR_NO_RANDOMIZE) { \
+	  int i;							\
+	  char **n;							\
+	  for (i=0;envp[i];i++);					\
+	  n=alloca((i+2)*sizeof(*n));					\
+	  n[i+1]=0;							\
+	  n[i--]="GCL_UNRANDOMIZE=t";					\
+	  for (;i>=0;i--)						\
+	    n[i]=envp[i];						\
+	  GPROF_CLEANUP;						\
+	  errno=0;							\
+	  execve(*argv,argv,n);						\
+	  printf("execve failure %d\n",errno);				\
+	  exit(-1);							\
+	} else {							\
+	  printf("personality change failure %d\n",errno);		\
+	  exit(-1);							\
+	}								\
+      }									\
+    }									\
+  } while (0)
+#else
+# define UNRANDOMIZE_SBRK
 #endif
-	errno=0;
-	execve(*argv,argv,n);
-	printf("execve failure %d\n",errno);
-	exit(-1);
-      } else {
-	printf("personality change failure %d\n",errno);
-	exit(-1);
-      }
-    }
-  }
-}
diff -dur gcl-2.6.8.ORIG/o/main.c gcl-2.6.8/o/main.c
--- gcl-2.6.8.ORIG/o/main.c	2010-01-12 07:19:15.000000000 -0700
+++ gcl-2.6.8/o/main.c	2010-03-23 11:22:09.805058642 -0600
@@ -51,6 +51,7 @@
 #include <signal.h>
 #endif
 #include "page.h"
+#include "unrandomize.h"
 
 bool saving_system ;
 
@@ -143,11 +144,7 @@
 #endif	
 	*argv=kcl_self;
 
-#ifdef CAN_UNRANDOMIZE_SBRK
-#include <stdio.h>
-#include <stdlib.h>
-#include "unrandomize.h"
-#endif
+	UNRANDOMIZE_SBRK;
 
 #if defined(DARWIN)
 	{