<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/919477

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-83) unstable; urgency=high

  * Version_2_6_13pre75
  * FIx acl2 arm builds (Closes: #919477).

Gbp-Pq: Name Version_2_6_13pre76

configure
configure.in
h/armhf-linux.h [new file with mode: 0644]
h/elf32_arm_reloc.h
h/elf32_arm_reloc_special.h
h/elf32_armhf_reloc.h [new file with mode: 0644]
h/elf32_armhf_reloc_special.h [new file with mode: 0644]
makedefc.in
o/unexelf.c

index 593e08074b2a3529d65574af87931004a4fae7e1..89e3f711da0bece91a412c19d8c65ef09f046781 100755 (executable)
--- a/configure
+++ b/configure
@@ -2679,6 +2679,7 @@ case $canonical in
     mipsel*linux*) use=mipsel-linux;;
     sparc*linux*) use=sparc-linux;;
     aarch64*linux*) use=aarch64-linux;;
+    arm*linux*hf) use=armhf-linux;;
     arm*linux*) use=arm-linux;;
     s390*linux*) use=s390-linux;;
     ia64*linux*) use=ia64-linux;;
@@ -4122,11 +4123,12 @@ $as_echo_n "checking working gprof... " >&6; }
                       sh4*)  enableval="no";;
                       ia64*) enableval="no";;
                       hppa*) enableval="no";;
-#                     arm*)  enableval="no";;#FIXME mcount compiled as a 24/22 bit reloc even with -mlong-calls, marginally accessible
+#                     arm*)  if echo $canonical |grep -q hf$; then enableval="no"; fi;;#FIXME CALL and JUMP24 veneers needed for thumb 20190201 #FIXME mcount compiled as a 24/22 bit reloc even with -mlong-calls, marginally accessible
                       aarch64*) enableval="no";;#unreproducible buildd bug 20170824
                       *gnu)  enableval="no";;
                   esac
-                  if test "$enableval" != "yes" ; then
+                   GP_FLAG=""
+                   if test "$enableval" != "yes" ; then
                       { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
 $as_echo "disabled" >&6; }
                   else
@@ -4134,7 +4136,8 @@ $as_echo "disabled" >&6; }
 $as_echo "ok" >&6; }
                       OLD_CFLAGS=$CFLAGS  # Do not run configure tests with -pg
                        assert_arg_to_cflags -pg
-                      CFLAGS=$OLD_CFLAGS
+                       GP_FLAG="-pg"
+                       CFLAGS=$OLD_CFLAGS
                               TFPFLAG=""
 
 $as_echo "#define GCL_GPROF 1" >>confdefs.h
@@ -4180,8 +4183,11 @@ 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*)
-#              assert_arg_to_cflags -mlong-calls
                assert_arg_to_cflags -fdollars-in-identifiers
                assert_arg_to_cflags -g #?
                ;;
@@ -9051,6 +9057,7 @@ LDFLAGS="`echo $LDFLAGS | sed 's,gcl.script,../unixport/gcl.script,g'`"
 
 LIBS="$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $LIBS $TLIBS"
 
+CFLAGS="$CFLAGS $GP_FLAG"
 FINAL_CFLAGS="$CFLAGS $CPPFLAGS $X_CFLAGS"
 
 # Work around bug with gcc on ppc -- CM
index 3d195c8dd5e1b76281a2db8dcf4802150aac0e2b..1d32735f07d23954bfbfaef79952884057a574fd 100644 (file)
@@ -37,6 +37,7 @@ case $canonical in
     mipsel*linux*) use=mipsel-linux;;
     sparc*linux*) use=sparc-linux;;
     aarch64*linux*) use=aarch64-linux;;
+    arm*linux*hf) use=armhf-linux;;
     arm*linux*) use=arm-linux;;
     s390*linux*) use=s390-linux;;
     ia64*linux*) use=ia64-linux;;
@@ -335,17 +336,19 @@ AC_ARG_ENABLE([gprof],[  --enable-gprof builds gcl with -pg in CFLAGS to enable
                       sh4*)  enableval="no";;
                       ia64*) enableval="no";;
                       hppa*) enableval="no";;
-#                     arm*)  enableval="no";;#FIXME mcount compiled as a 24/22 bit reloc even with -mlong-calls, marginally accessible
+#                     arm*)  if echo $canonical |grep -q hf$; then enableval="no"; fi;;#FIXME CALL and JUMP24 veneers needed for thumb 20190201 #FIXME mcount compiled as a 24/22 bit reloc even with -mlong-calls, marginally accessible
                       aarch64*) enableval="no";;#unreproducible buildd bug 20170824
                       *gnu)  enableval="no";;
                   esac              
-                  if test "$enableval" != "yes" ; then
+                   GP_FLAG=""
+                   if test "$enableval" != "yes" ; then
                       AC_MSG_RESULT([disabled])
                   else
                       AC_MSG_RESULT([ok])
                       OLD_CFLAGS=$CFLAGS  # Do not run configure tests with -pg
                        assert_arg_to_cflags -pg
-                      CFLAGS=$OLD_CFLAGS
+                       GP_FLAG="-pg"
+                       CFLAGS=$OLD_CFLAGS
                               TFPFLAG=""
                       AC_DEFINE(GCL_GPROF,1,[use gprof profiling])
                   fi
@@ -387,8 +390,11 @@ 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*)
-#              assert_arg_to_cflags -mlong-calls
                assert_arg_to_cflags -fdollars-in-identifiers
                assert_arg_to_cflags -g #?
                ;;
@@ -2108,6 +2114,7 @@ LDFLAGS="`echo $LDFLAGS | sed 's,gcl.script,../unixport/gcl.script,g'`"
 AC_SUBST(LDFLAGS)
 LIBS="$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $LIBS $TLIBS"
 AC_SUBST(LIBS)
+CFLAGS="$CFLAGS $GP_FLAG"
 FINAL_CFLAGS="$CFLAGS $CPPFLAGS $X_CFLAGS"
 AC_SUBST(FINAL_CFLAGS)
 # Work around bug with gcc on ppc -- CM
diff --git a/h/armhf-linux.h b/h/armhf-linux.h
new file mode 100644 (file)
index 0000000..e016c2b
--- /dev/null
@@ -0,0 +1,17 @@
+#include "linux.h"
+
+#ifdef IN_GBC
+#undef MPROTECT_ACTION_FLAGS
+#define MPROTECT_ACTION_FLAGS SA_RESTART|SA_SIGINFO
+#define GET_FAULT_ADDR(sig,code,sv,a) \
+ ((siginfo_t *)code)->si_addr
+/*  #define GET_FAULT_ADDR(sig,code,sv,a) \ */
+/*      ((void *)(*((char ***)(&code)))[44]) */
+#endif
+
+#define SGC
+
+#define RELOC_H "elf32_armhf_reloc.h"
+#define SPECIAL_RELOC_H "elf32_armhf_reloc_special.h"
+
+#define NEED_STACK_CHK_GUARD
index 6a504e4eda1345f4d036a31a131aa1a7932d97ba..abeeac9cfa12120124bc9d1677be3f8899d9c5bf 100644 (file)
@@ -1,44 +1,7 @@
-#define R_ARM_THM_CALL        10
-#define R_ARM_CALL 28
-#define R_ARM_V4BX 40
-#define R_ARM_THM_MOVW_ABS_NC 47
-#define R_ARM_THM_MOVW_ABS    48
 #define R_ARM_MOVW_ABS_NC 43
 #define R_ARM_MOVT_ABS    44
-    case R_ARM_THM_JUMP24:
-      s+=a; 
-      if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) s|=1; 
-      s-=p+4; /*FIXME maybe drop 4 and add_val below*/
-      s=((long)s>>1); 
-      massert(!(abs(s)&0xff000000));  
-      store_val(where,MASK(11)<<16,(s&0x7ff)<<16); 
-      store_val(where,MASK(10),s>>11); 
-      store_val(where,MASK(1)<<(16+11),(~((s>>21&0x1)^(s>>23&0x1)))<<(16+11)); 
-      store_val(where,MASK(1)<<(16+13),(~((s>>22&0x1)^(s>>23&0x1)))<<(16+13)); 
-      store_val(where,MASK(1)<<10,(s>>23&0x1)<<10); 
-      break; 
-    case R_ARM_THM_CALL: 
-      s+=a; 
-      if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) s|=1; 
-      s-=p+4; /*FIXME maybe drop 4 and add_val below*/
-      s=((long)s>>1); 
-      massert(!(abs(s)&0xffc00000));  
-      store_val(where,MASK(11),s>>11); 
-      store_val(where,MASK(11)<<16,(s&0x7ff)<<16); 
-      break; 
-    case R_ARM_THM_MOVW_ABS_NC:
-      s+=a;
-      if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) s|=1;
-      s&=0xffff;
-      s=((s>>12)&0xf)|(((s>>11)&0x1)<<10)|((s&0xff)<<16)|(((s>>8)&0x7)<<28);
-      add_vals(where,~0L,s);
-      break;
-    case R_ARM_THM_MOVW_ABS:
-      s+=a;
-      s>>=16;
-      s=((s>>12)&0xf)|(((s>>11)&0x1)<<10)|((s&0xff)<<16)|(((s>>8)&0x7)<<28);
-      add_vals(where,~0L,s);
-      break;
+#define R_ARM_CALL 28
+#define R_ARM_V4BX 40
     case R_ARM_MOVW_ABS_NC:
       s+=a;
       s&=0xffff;
       break;
     case R_ARM_CALL:
     case R_ARM_JUMP24:
-      massert(!a);
       {
-       long x=((long)(s-p))/4;
-       if (abs(x)&(~MASK(23))) {
+       long x=((long)(s+a-p))/4;
+       if (abs(x)&(~MASK(23))) {/*24?*/
           got+=(sym->st_size-1)*tz;
          memcpy(got,tramp,sizeof(tramp));
+         /*relocate*/
           got[sizeof(tramp)/sizeof(*got)]=s;
          x=((long)got-p)/4;
        }
        add_vals(where,MASK(24),x);
       }
       break;
-    case R_ARM_ABS32:
+    case R_ARM_V4BX:
       add_vals(where,~0L,s+a);
       break;
-    case R_ARM_V4BX:
+    case R_ARM_ABS32:
       add_vals(where,~0L,s+a);
       break;
index 0c3b6928082a0d091dfdb31056c573f55178fb7d..9926a46cafdb3674a6e858330cb95902c54b042d 100644 (file)
@@ -1,9 +1,7 @@
-/* #define R_AARCH64_TRAMP 1 */
-static int tramp[]={0xe59fc000,  /*ldr r12, [pc]*/ /*FIXME?  Can this refer to an earlier address?*/
-                   0xe12fff1c}; /*br r12*/
+static int tramp[]={0xe59fc000,   /*ldr r12, [pc]*/ /*FIXME?  Can this refer to an earlier address?*/
+                   0xe12fff1c};  /*br r12*/
 static ul tz=1+sizeof(tramp)/sizeof(ul);
 
-
 static int
 find_special_params(void *v,Shdr *sec1,Shdr *sece,const char *sn,
                    const char *st1,Sym *ds1,Sym *dse,Sym *sym,Sym *syme) {
@@ -26,8 +24,10 @@ label_got_symbols(void *v1,Shdr *sec1,Shdr *sece,Sym *sym1,Sym *syme,const char
   for (*gs=0,sec=sec1;sec<sece;sec++)
     if (sec->sh_type==SHT_REL)
       for (v=v1+sec->sh_offset,ve=v+sec->sh_size,r=v;v<ve;v+=sec->sh_entsize,r=v)
-       if (ELF_R_TYPE(r->r_info)==R_ARM_CALL ||
-           ELF_R_TYPE(r->r_info)==R_ARM_JUMP24) {
+       if (
+           ELF_R_TYPE(r->r_info)==R_ARM_CALL ||
+           ELF_R_TYPE(r->r_info)==R_ARM_JUMP24
+           ) {
 
          sym=sym1+ELF_R_SYM(r->r_info);
 
diff --git a/h/elf32_armhf_reloc.h b/h/elf32_armhf_reloc.h
new file mode 100644 (file)
index 0000000..2f31665
--- /dev/null
@@ -0,0 +1,71 @@
+#define R_ARM_THM_CALL        10
+#define R_ARM_THM_MOVW_ABS_NC 47
+#define R_ARM_THM_MOVW_ABS    48
+     case R_ARM_THM_JUMP24:
+      {
+       long x=(long)(s+a-p);
+       if (1||abs(x)&(~MASK(25))) {
+
+          got+=(sym->st_size-1)*tz;
+         memcpy(got,tramp,sizeof(tramp));
+
+         r->r_offset=(void *)got-(void *)start;
+         r->r_info=ELF_R_INFO(ELF_R_SYM(r->r_info),R_ARM_THM_MOVW_ABS_NC);
+         relocate(sym1,r,0,start,got,gote);
+
+         r->r_offset=(void *)(got+1)-(void *)start;
+         r->r_info=ELF_R_INFO(ELF_R_SYM(r->r_info),R_ARM_THM_MOVW_ABS);
+         relocate(sym1,r,0,start,got,gote);
+
+         x=((long)got-p);
+       }
+        if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) x|=1;
+        x-=4; /*FIXME maybe drop 4 and add_val below*/
+        x=((long)x>>1);
+        store_val(where,MASK(11)<<16,(x&0x7ff)<<16);
+        store_val(where,MASK(10),x>>11);
+        store_val(where,MASK(1)<<(16+11),(~((x>>21&0x1)^(x>>23&0x1)))<<(16+11));
+        store_val(where,MASK(1)<<(16+13),(~((x>>22&0x1)^(x>>23&0x1)))<<(16+13));
+        store_val(where,MASK(1)<<10,(x>>23&0x1)<<10);
+      }
+      break;
+    case R_ARM_THM_CALL:
+      {
+       long x=(long)(s+a-p);
+       if (1||abs(x)&(~MASK(23))) {/*24?*/
+          got+=(sym->st_size-1)*tz;
+         memcpy(got,tramp,sizeof(tramp));
+
+         r->r_offset=(void *)got-(void *)start;
+         r->r_info=ELF_R_INFO(ELF_R_SYM(r->r_info),R_ARM_THM_MOVW_ABS_NC);
+         relocate(sym1,r,0,start,got,gote);
+
+         r->r_offset=(void *)(got+1)-(void *)start;
+         r->r_info=ELF_R_INFO(ELF_R_SYM(r->r_info),R_ARM_THM_MOVW_ABS);
+         relocate(sym1,r,0,start,got,gote);
+
+         x=((long)got-p);
+       }
+        if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) x|=1;
+        x-=4; /*FIXME maybe drop 4 and add_val below*/
+        x=((long)x>>1);
+        store_val(where,MASK(11),x>>11);
+        store_val(where,MASK(11)<<16,(x&0x7ff)<<16);
+      }
+      break;
+    case R_ARM_THM_MOVW_ABS_NC:
+      s+=a;
+      if (ELF_ST_TYPE(sym->st_info)==STT_FUNC) s|=1;
+      s&=0xffff;
+      s=((s>>12)&0xf)|(((s>>11)&0x1)<<10)|((s&0xff)<<16)|(((s>>8)&0x7)<<28);
+      add_vals(where,~0L,s);
+      break;
+    case R_ARM_THM_MOVW_ABS:
+      s+=a;
+      s>>=16;
+      s=((s>>12)&0xf)|(((s>>11)&0x1)<<10)|((s&0xff)<<16)|(((s>>8)&0x7)<<28);
+      add_vals(where,~0L,s);
+      break;
+    case R_ARM_ABS32:
+      add_vals(where,~0L,s+a);
+      break;
diff --git a/h/elf32_armhf_reloc_special.h b/h/elf32_armhf_reloc_special.h
new file mode 100644 (file)
index 0000000..56d35a1
--- /dev/null
@@ -0,0 +1,85 @@
+static int tramp[]={0x0c00f240,  /*movw        r12, #0*/
+                   0x0c00f2c0,  /*movt r12, #0*/
+                   0xbf004760}; /*bx r12   nop*/
+static ul tz=sizeof(tramp)/sizeof(ul);
+
+static ul *
+next_plt_entry(ul *p,ul *pe) {
+
+  ul l0=0xe5bef000,/*ldr pc,[ip,#]*/
+     l1=0xe5bcf000;/*ldr pc,[lr,#]*/
+
+  for (;p<pe && (*p&l0)!=l0 && (*p&l1)!=l1;p++);
+  if ((*p&l0)==l0) p++;
+
+  return p+1;
+
+}
+
+static int
+find_special_params(void *v,Shdr *sec1,Shdr *sece,const char *sn,
+                   const char *st1,Sym *ds1,Sym *dse,Sym *sym,Sym *syme) {
+
+  Shdr *sec,*psec;
+  Rel *r;
+  ul *p,*pe;
+  void *ve;
+
+  /*plt entries are not of uniform size*/
+
+  massert(psec=get_section(".plt",sec1,sece,sn));
+  p=(void *)psec->sh_addr;
+  pe=(void *)p+psec->sh_size;
+
+  massert((sec=get_section( ".rel.plt",sec1,sece,sn)) ||
+         (sec=get_section(".rela.plt",sec1,sece,sn)));
+
+  v+=sec->sh_offset;
+  ve=v+sec->sh_size;
+
+  p=next_plt_entry(p,pe);/*plt0*/
+
+  for (r=v;v<ve && p<pe;v+=sec->sh_entsize,r=v,p=next_plt_entry(p,pe)) {
+    if (!ds1[ELF_R_SYM(r->r_info)].st_value)
+      ds1[ELF_R_SYM(r->r_info)].st_value=(ul)p;
+  }
+
+  massert(p==pe);
+  massert(v==ve);
+
+  return 0;
+
+}
+
+static int
+label_got_symbols(void *v1,Shdr *sec1,Shdr *sece,Sym *sym1,Sym *syme,const char *st1,const char *sn,ul *gs) {
+
+  Rel *r;
+  Sym *sym;
+  Shdr *sec;
+  void *v,*ve;
+
+  for (sym=sym1;sym<syme;sym++)
+    sym->st_size=0;
+
+  for (*gs=0,sec=sec1;sec<sece;sec++)
+    if (sec->sh_type==SHT_REL)
+      for (v=v1+sec->sh_offset,ve=v+sec->sh_size,r=v;v<ve;v+=sec->sh_entsize,r=v)
+       if (
+#define R_ARM_THM_CALL        10
+           ELF_R_TYPE(r->r_info)==R_ARM_THM_CALL ||
+           ELF_R_TYPE(r->r_info)==R_ARM_THM_JUMP24
+           ) {
+
+         sym=sym1+ELF_R_SYM(r->r_info);
+
+         if (!sym->st_size)
+           sym->st_size=++*gs;
+
+       }
+
+  (*gs)*=tz;
+
+  return 0;
+
+}
index a284f08a41f5ccdf02569f9b35d6d6c04a2a0795..4570d0912c5d49703e72988c9cefe53d58665d3a 100644 (file)
@@ -6,10 +6,6 @@
 # for main link of raw_gcl
 LIBS=@LIBS@
 
-#The multi precision library stuff
-MPFILES=$(MPDIR)/@MPI_FILE@ $(MPDIR)/libmport.a
-
-
 # root for the installation, eg /usr/local
 # This would cause make install to create /usr/local/bin/gcl and
 # /usr/local/lib/gcl-2-??/* with some basic files.
index 78dc68eb208f812d912c17e11ca588051676d068..9b90701f9be19734828b94aceb838c15874e7246 100755 (executable)
@@ -887,7 +887,7 @@ unexec (char *new_name, char *old_name, unsigned int data_start, unsigned int bs
 
   /* Walk through all section headers, insert the new data2 section right
      before the new bss section. */
-  for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++)
+  for (n = 0, nn = 0; n < (int) old_file_h->e_shnum; n++, nn++)
     {
       caddr_t src;
       /* If it is (s)bss section, insert the new data2 section before it.  */