<short summary of the patch>
authorCamm Maguire <camm@debian.org>
Sun, 13 Nov 2022 12:55:14 +0000 (12:55 +0000)
committerCamm Maguire <camm@debian.org>
Sun, 13 Nov 2022 12:55:14 +0000 (12:55 +0000)
Bug-Debian: https://bugs.debian.org/993480

TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.

gcl (2.6.12-103) unstable; urgency=medium

  * Bug fix: "Fails to install in unstable", thanks to Samuel Thibault
    (Closes: #993480).

Gbp-Pq: Name Version_2_6_13pre100

configure
configure.in
h/att_ext.h
h/elf32_armhf_reloc.h
h/gclincl.h.in
h/unrandomize.h
o/main.c

index 40d8ed1e35a4b21845d2c4128fb52f55480d127a..eeb4f7990c83b1299f384b254c3a9a68460066ba 100755 (executable)
--- a/configure
+++ b/configure
@@ -761,6 +761,7 @@ enable_gprof
 enable_dynsysgmp
 with_x
 enable_xdr
+enable_cstackmax
 enable_immfix
 enable_fastimmfix
 enable_ansi
@@ -1429,6 +1430,7 @@ Optional Features:
   --enable-gprof builds gcl with -pg in CFLAGS to enable profiling with gprof
   --enable-dynsysgmp will link against the system libgmp3 overriding certain functions with patched versions from the local source
   --enable-xdr=yes will compile in support for XDR
+  --enable-cstackmax=xxxx will ensure that the cstack begins below xxxx or fail
   --enable-immfix will enable an immediate fixnum table above the C stack
   --enable-fastimmfix=XXXX will reject low immediate fixnums unless 2^XXX can be attained
   --enable-ansi builds a large gcl aiming for ansi compliance
@@ -4186,11 +4188,14 @@ case $use in
            ia64*)
                if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.8.1
                ;;
-           armhf*)
-               assert_arg_to_cflags -fdollars-in-identifiers
-               assert_arg_to_cflags -g #?
-               ;;
            arm*)
+
+$as_echo "#define SET_STACK_POINTER \"mov %%sp,%0\\n\\t\"" >>confdefs.h
+
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to set stack pointer" >&5
+$as_echo_n "checking how to set stack pointer... " >&6; }
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
                assert_arg_to_cflags -fdollars-in-identifiers
                assert_arg_to_cflags -g #?
                ;;
@@ -6673,24 +6678,12 @@ else
 
                #include <stdio.h>
                #include <stdlib.h>
-
-               unsigned long w;
-
-               void
-               foo(void) {
-                   int i;
-                   w=(unsigned long)&i;
-               }
-
-               int
-               main(int argc,char **argv,char **envp) {
-                   void *b;
+               int main(int argc,char **argv,char **envp) {
                    FILE *fp = fopen("conftest1","w");
                    #ifdef CAN_UNRANDOMIZE_SBRK
                    #include "h/unrandomize.h"
                    #endif
-                   foo();
-                   fprintf(fp,"%d",((unsigned long) &b) > w ? -1 : 1);
+                   fprintf(fp,"%d",(alloca(sizeof(void *))>alloca(sizeof(void *))) ? -1 : 1);
                    fclose(fp);
                    return 0;
                }
@@ -6712,6 +6705,62 @@ _ACEOF
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cstack_direction" >&5
 $as_echo "$cstack_direction" >&6; }
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking finding CSTACK_ALIGNMENT" >&5
+$as_echo_n "checking finding CSTACK_ALIGNMENT... " >&6; }
+if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+               #include <stdio.h>
+               #include <stdlib.h>
+               int main(int argc,char **argv,char **envp) {
+                   void *b,*c;
+                   FILE *fp = fopen("conftest1","w");
+                   long n;
+                   #ifdef CAN_UNRANDOMIZE_SBRK
+                   #include "h/unrandomize.h"
+                   #endif
+                   b=alloca(sizeof(b));
+                   c=alloca(sizeof(c));
+                   n=b>c ? b-c : c-b;
+                   n=n>sizeof(c) ? n : 1;
+                   fprintf(fp,"%ld",n);
+                   fclose(fp);
+                   return 0;
+               }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  cstack_alignment=`cat conftest1`
+else
+  cstack_alignment=0
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define CSTACK_ALIGNMENT $cstack_alignment
+_ACEOF
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cstack_alignment" >&5
+$as_echo "$cstack_alignment" >&6; }
+
+# Check whether --enable-cstackmax was given.
+if test "${enable_cstackmax+set}" = set; then :
+  enableval=$enable_cstackmax; if test "$enableval" != "" ; then
+cat >>confdefs.h <<_ACEOF
+#define CSTACKMAX $enableval
+_ACEOF
+ fi
+fi
+
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking CSTACK_ADDRESS" >&5
 $as_echo_n "checking CSTACK_ADDRESS... " >&6; }
@@ -6728,7 +6777,6 @@ else
                #include <stdlib.h>
                int
                main(int argc,char **argv,char **envp) {
-                   void *v ;
                    FILE *fp = fopen("conftest1","w");
                    unsigned long i,j;
 
@@ -6738,7 +6786,7 @@ else
                    j=1;
                    j<<=$PAGEWIDTH;
                    j<<=16;
-                   i=(unsigned long)&v;
+                   i=(unsigned long)alloca(sizeof(void *));
                    if ($cstack_direction==1) i-=j;
                    j--;
                    i+=j;
@@ -6856,52 +6904,6 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking finding CSTACK_ALIGNMENT" >&5
-$as_echo_n "checking finding CSTACK_ALIGNMENT... " >&6; }
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-               #include <stdio.h>
-               #include <stdlib.h>
-               int main(int argc,char **argv,char **envp) {
-                   void *b,*c;
-                   FILE *fp = fopen("conftest1","w");
-                   long n;
-                   #ifdef CAN_UNRANDOMIZE_SBRK
-                   #include "h/unrandomize.h"
-                   #endif
-                   b=alloca(sizeof(b));
-                   c=alloca(sizeof(c));
-                   n=b>c ? b-c : c-b;
-                   n=n>sizeof(c) ? n : 1;
-                   fprintf(fp,"%ld",n);
-                   fclose(fp);
-                   return 0;
-               }
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  cstack_alignment=`cat conftest1`
-else
-  cstack_alignment=0
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define CSTACK_ALIGNMENT $cstack_alignment
-_ACEOF
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cstack_alignment" >&5
-$as_echo "$cstack_alignment" >&6; }
-
 # Check whether --enable-immfix was given.
 if test "${enable_immfix+set}" = set; then :
   enableval=$enable_immfix;
index abb5dc5f053b009c080e43b5e24e5d8d895ccd33..dc24d5e6947a665ed9d080ac81db9a9ef1558331 100644 (file)
@@ -393,11 +393,10 @@ case $use in
            ia64*)
                if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.8.1
                ;;
-           armhf*)
-               assert_arg_to_cflags -fdollars-in-identifiers
-               assert_arg_to_cflags -g #?
-               ;;
            arm*)
+               AC_DEFINE([SET_STACK_POINTER],["mov %%sp,%0\n\t"],[asm string to set the stack pointer])
+               AC_MSG_CHECKING([how to set stack pointer])
+               AC_MSG_RESULT([done])
                assert_arg_to_cflags -fdollars-in-identifiers
                assert_arg_to_cflags -g #?
                ;;
@@ -1196,24 +1195,12 @@ AC_RUN_IFELSE(
            [[
                #include <stdio.h>
                #include <stdlib.h>
-
-               unsigned long w;
-
-               void
-               foo(void) {
-                   int i;
-                   w=(unsigned long)&i;
-               }
-               
-               int
-               main(int argc,char **argv,char **envp) {
-                   void *b;
+               int main(int argc,char **argv,char **envp) {
                    FILE *fp = fopen("conftest1","w");
                    #ifdef CAN_UNRANDOMIZE_SBRK
                    #include "h/unrandomize.h"
                    #endif
-                   foo();
-                   fprintf(fp,"%d",((unsigned long) &b) > w ? -1 : 1);
+                   fprintf(fp,"%d",(alloca(sizeof(void *))>alloca(sizeof(void *))) ? -1 : 1);
                    fclose(fp);
                    return 0;
                }]])],
@@ -1221,6 +1208,34 @@ AC_RUN_IFELSE(
 AC_DEFINE_UNQUOTED(CSTACK_DIRECTION,$cstack_direction,[whether C stack grows up or down])
 AC_MSG_RESULT($cstack_direction)
 
+AC_MSG_CHECKING([finding CSTACK_ALIGNMENT])
+AC_RUN_IFELSE(
+    [AC_LANG_SOURCE(
+           [[
+               #include <stdio.h>
+               #include <stdlib.h>
+               int main(int argc,char **argv,char **envp) {
+                   void *b,*c;
+                   FILE *fp = fopen("conftest1","w");
+                   long n;
+                   #ifdef CAN_UNRANDOMIZE_SBRK
+                   #include "h/unrandomize.h"
+                   #endif
+                   b=alloca(sizeof(b));
+                   c=alloca(sizeof(c));
+                   n=b>c ? b-c : c-b;
+                   n=n>sizeof(c) ? n : 1;
+                   fprintf(fp,"%ld",n);
+                   fclose(fp);
+                   return 0;
+               }]])],
+    [cstack_alignment=`cat conftest1`],[cstack_alignment=0])
+AC_DEFINE_UNQUOTED(CSTACK_ALIGNMENT,$cstack_alignment,[C stack alignment])
+AC_MSG_RESULT($cstack_alignment)
+
+AC_ARG_ENABLE([cstackmax],[  --enable-cstackmax=xxxx will ensure that the cstack begins below xxxx or fail],
+             [if test "$enableval" != "" ; then AC_DEFINE_UNQUOTED([CSTACKMAX],$enableval,[cstack max]) fi])
+
 
 AC_MSG_CHECKING(CSTACK_ADDRESS)
 AC_RUN_IFELSE(
@@ -1230,7 +1245,6 @@ AC_RUN_IFELSE(
                #include <stdlib.h>
                int
                main(int argc,char **argv,char **envp) {
-                   void *v ;
                    FILE *fp = fopen("conftest1","w");
                    unsigned long i,j;
                    
@@ -1240,7 +1254,7 @@ AC_RUN_IFELSE(
                    j=1;
                    j<<=$PAGEWIDTH;
                    j<<=16;
-                   i=(unsigned long)&v;
+                   i=(unsigned long)alloca(sizeof(void *));
                    if ($cstack_direction==1) i-=j;
                    j--;
                    i+=j;
@@ -1304,31 +1318,6 @@ AC_RUN_IFELSE(
     [AC_MSG_RESULT(no)
      neg_cstack_address=0])
 
-AC_MSG_CHECKING([finding CSTACK_ALIGNMENT])
-AC_RUN_IFELSE(
-    [AC_LANG_SOURCE(
-           [[
-               #include <stdio.h>
-               #include <stdlib.h>
-               int main(int argc,char **argv,char **envp) {
-                   void *b,*c;
-                   FILE *fp = fopen("conftest1","w");
-                   long n;
-                   #ifdef CAN_UNRANDOMIZE_SBRK
-                   #include "h/unrandomize.h"
-                   #endif
-                   b=alloca(sizeof(b));
-                   c=alloca(sizeof(c));
-                   n=b>c ? b-c : c-b;
-                   n=n>sizeof(c) ? n : 1;
-                   fprintf(fp,"%ld",n);
-                   fclose(fp);
-                   return 0;
-               }]])],
-    [cstack_alignment=`cat conftest1`],[cstack_alignment=0])
-AC_DEFINE_UNQUOTED(CSTACK_ALIGNMENT,$cstack_alignment,[C stack alignment])
-AC_MSG_RESULT($cstack_alignment)
-
 AC_ARG_ENABLE([immfix],[  --enable-immfix will enable an immediate fixnum table above the C stack])
 
 AC_ARG_ENABLE([fastimmfix],[  --enable-fastimmfix=XXXX will reject low immediate fixnums unless 2^XXX can be attained],,[enable_fastimmfix=64])
index 7c81b6df6b1f8bc1e259823936b6c370a19c22a5..2c099fbdf94051dc4730cf7e2aa96b4586b61eee 100755 (executable)
@@ -272,12 +272,7 @@ object macro_expand();
 
 /*  main.c  */
 EXTER char* system_directory;
-EXTER int ARGC;
-EXTER char **ARGV;
 void error();
-#ifdef UNIX
-EXTER char **ENVP;
-#endif
 object vs_overflow(void);
 
 EXTER object sSAsystem_directoryA;
index 1458fa6d19c665ef832463ab54772f2869be0f7c..1f0f756b00c78bb8232a41aae2b73bc870271f97 100644 (file)
@@ -4,7 +4,7 @@
      case R_ARM_THM_JUMP24:
       {
        long x=(long)(s+a-p);
-       if (abs(x)&(~MASK(22))) {
+       if (abs(x)&(~MASK(23))) {
 
           got+=(sym->st_size-1)*tz;
          memcpy(got,tramp,sizeof(tramp));
index 1f8411ab04538beca28d931bc0d5ebdff0b20b0b..7960206d9d5b1088757095d89096b4bd268c0145 100644 (file)
@@ -26,6 +26,9 @@
    */
 #undef CRAY_STACKSEG_END
 
+/* cstack max */
+#undef CSTACKMAX
+
 /* starting C stack address */
 #undef CSTACK_ADDRESS
 
 /* system pagewidth */
 #undef PAGEWIDTH
 
+/* asm string to set the stack pointer */
+#undef SET_STACK_POINTER
+
 /* have sigcontext of signal.h */
 #undef SIGNAL_H_HAS_SIGCONTEXT
 
index a11374b38b47a6bc8f2193264787b4cdfcee3311..00ddb887eb4f0d3b6d0b2e5f19c29a5b9ce0fc6c 100644 (file)
@@ -1,4 +1,5 @@
 #include <sys/personality.h>
+#include <sys/mman.h>
 #include <syscall.h>
 #include <unistd.h>
 #include <string.h>
        exit(-1);
       }
     }
+#if defined(CSTACKMAX) && CSTACK_DIRECTION < 0
+    if ((void *)&argc > (void *)CSTACKMAX) {
+      if (mmap((void *)CSTACKMAX-(1L << PAGEWIDTH),(1L << PAGEWIDTH),
+              PROT_READ|PROT_WRITE|PROT_EXEC,MAP_FIXED|MAP_PRIVATE|MAP_ANON|MAP_STACK|MAP_GROWSDOWN,-1,0)==(void *)-1) {
+       printf("cannot mmap new stack %d\n",errno);
+       exit(-1);
+      }
+#ifdef SET_STACK_POINTER
+      {void *p=(void *)CSTACKMAX-4*CSTACK_ALIGNMENT;asm volatile (SET_STACK_POINTER::"r" (p):"memory");}
+#else
+#error Cannot set stack pointer
+#endif
+    }
+#endif
+
   }
 }
index 9bd4fb4df0858c5462de3e6781b71fc7d1fa0218..bcd4cae69c67a860b0bf959485b85e4140ec2156 100755 (executable)
--- a/o/main.c
+++ b/o/main.c
@@ -503,6 +503,9 @@ which(const char *n,char *o) {
 
 #endif
 
+static int ARGC;
+static char **ARGV;
+
 int
 main(int argc, char **argv, char **envp) {
 
@@ -515,7 +518,7 @@ main(int argc, char **argv, char **envp) {
 #include "unrandomize.h"
 #endif
 
-  gcl_init_alloc(&argv);
+  gcl_init_alloc(alloca(1));
 
   setbuf(stdin, stdin_buf); 
   setbuf(stdout, stdout_buf);
@@ -527,7 +530,6 @@ main(int argc, char **argv, char **envp) {
 #endif
   ARGC = argc;
   ARGV = argv;
-  ENVP = envp;
   
   vs_top = vs_base = vs_org;
   ihs_top = ihs_org-1;
@@ -539,9 +541,9 @@ main(int argc, char **argv, char **envp) {
     printf("GCL (GNU Common Lisp)  %s  %ld pages\n",LISP_IMPLEMENTATION_VERSION,real_maxpage);
     fflush(stdout);
     
-    if (argc>1) {
-      massert(argv[1][strlen(argv[1])-1]=='/');
-      system_directory=argv[1];
+    if (ARGC>1) {
+      massert(ARGV[1][strlen(ARGV[1])-1]=='/');
+      system_directory=ARGV[1];
     }
 
     initlisp();