On Tue, Nov 4, 2008 at 9:04 AM, Jerry James <[EMAIL PROTECTED]> wrote:
> So here is a patch to move the #include statements out of functions.
> After applying this patch, configure will need to be regenerated.
Disregard that patch. It was incomplete, and is fundamentally the
wrong approach anyway. Here is a patch that does it the right way.
Unfortunately, regenerating configure with autoconf 2.61 after
applying this patch produces a configure script that fails to execute
all the way. That's due to some obsolete autoconf input in the
existing configure.in script. I'll post a separate patch to fix that
problem in a moment.
--
Jerry James
http://loganjerry.googlepages.com/
diff -dur gcl-2.6.7.ORIG/configure.in gcl-2.6.7/configure.in
--- gcl-2.6.7.ORIG/configure.in 2008-11-20 08:28:14.000000000 -0700
+++ gcl-2.6.7/configure.in 2008-11-20 08:28:51.000000000 -0700
@@ -1001,7 +1001,7 @@
FILE *f;
if (!(f=fopen("conftest1","w")))
return -1;
- fprintf(f,"%u",sbrk(0));
+ fprintf(f,"%lu",sbrk(0));
return 0;
}],
HAVE_SBRK=1
@@ -1032,10 +1032,14 @@
fi
AC_MSG_CHECKING([for personality(ADDR_NO_RANDOMIZE) support])
- AC_TRY_RUN([void gprof_cleanup() {};
+ 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"
- return 0;}],CAN_UNRANDOMIZE_SBRK=1,CAN_UNRANDOMIZE_SBRK=0,CAN_UNRANDOMIZE_SBRK=0)
+ UNRANDOMIZE_SBRK();
+ return 0;}]])],
+ CAN_UNRANDOMIZE_SBRK=1,CAN_UNRANDOMIZE_SBRK=0,CAN_UNRANDOMIZE_SBRK=0)
if test "$CAN_UNRANDOMIZE_SBRK" != 0 ; then
AC_MSG_RESULT(yes)
@@ -1045,30 +1049,30 @@
fi
AC_MSG_CHECKING([that sbrk is (now) non-random])
- AC_TRY_RUN([#include <stdio.h>
- void gprof_cleanup() {};
+ 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)
+ fprintf(f,"%lu",sbrk(0));
+ return 0;}]])],SBRK=`cat conftest1`,SBRK=0,SBRK=0)
if test "$SBRK" = "0" ; then
AC_MSG_RESULT(cannot trap sbrk)
exit 1
fi
- AC_TRY_RUN([#include <stdio.h>
- void gprof_cleanup() {};
+ 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)
+ fprintf(f,"%lu",sbrk(0));
+ return 0;}]])],SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0)
if test "$SBRK1" = "0" ; then
AC_MSG_RESULT(cannot trap sbrk)
exit 1
@@ -1103,19 +1107,19 @@
old_LDFLAGS="$LDFLAGS"
LDFLAGS="$TLDFLAGS"
AC_MSG_CHECKING("finding DBEGIN")
-AC_TRY_RUN([#include <stdio.h>
- #include <stdlib.h>
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <stdlib.h>
+#include "h/unrandomize.h"
-void gprof_cleanup() {};
+void gprof_cleanup() {}
int
main(int argc,char * argv[],char *envp[])
{
char *b,*b1;
FILE *fp;
-#ifdef CAN_UNRANDOMIZE_SBRK
-#include "h/unrandomize.h"
-#endif
+ UNRANDOMIZE_SBRK();
b = (void *) malloc(1000);
fp = fopen("conftest1","w");
@@ -1131,7 +1135,7 @@
#endif
fclose(fp);
return 0;
-}],dbegin=`cat conftest1`,dbegin=0,dbegin=0)
+}]])],dbegin=`cat conftest1`,dbegin=0,dbegin=0)
AC_DEFINE_UNQUOTED(DBEGIN,$dbegin \
/* where data begins */
)
diff -dur gcl-2.6.7.ORIG/h/unrandomize.h gcl-2.6.7/h/unrandomize.h
--- gcl-2.6.7.ORIG/h/unrandomize.h 2008-11-20 08:28:15.000000000 -0700
+++ gcl-2.6.7/h/unrandomize.h 2008-11-20 08:28:51.000000000 -0700
@@ -1,25 +1,33 @@
+#include <stdlib.h>
#include <sys/personality.h>
#include <syscall.h>
#include <unistd.h>
#include <alloca.h>
-{
-
- long pers = personality(0xffffffffUL);
- if (!(pers & ADDR_NO_RANDOMIZE) && !getenv("GCL_UNRANDOMIZE"))
- 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 CAN_UNRANDOMIZE_SBRK
#ifdef GCL_GPROF
- gprof_cleanup();
+#define GPROF_CLEANUP gprof_cleanup()
+#else
+#define GPROF_CLEANUP
#endif
- execve(*argv,argv,n);
- }
-}
+#define UNRANDOMIZE_SBRK() do \
+{ \
+ long pers = personality(0xffffffffUL); \
+ if (!(pers & ADDR_NO_RANDOMIZE) && !getenv("GCL_UNRANDOMIZE")) \
+ 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; \
+ execve(*argv,argv,n); \
+ } \
+} while(0)
+#else
+#define UNRANDOMIZE_SBRK()
+#endif
diff -dur gcl-2.6.7.ORIG/o/main.c gcl-2.6.7/o/main.c
--- gcl-2.6.7.ORIG/o/main.c 2008-11-20 08:28:22.000000000 -0700
+++ gcl-2.6.7/o/main.c 2008-11-20 08:29:50.000000000 -0700
@@ -51,6 +51,7 @@
#include <signal.h>
#endif
#include "page.h"
+#include "unrandomize.h"
bool saving_system ;
@@ -125,9 +126,7 @@
#endif
#endif
-#ifdef CAN_UNRANDOMIZE_SBRK
-#include "unrandomize.h"
-#endif
+ UNRANDOMIZE_SBRK();
#if defined(DARWIN)
{
_______________________________________________
Gcl-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gcl-devel