From: Camm Maguire Date: Thu, 11 Aug 2022 17:16:42 +0000 (+0100) Subject: X-Git-Tag: archive/raspbian/2.7.1-4+rpi1~1^2~1^2~39 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7bffa185c737b1a94e748d6d72b1dc8b592ea056;p=gcl27.git 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 --- diff --git a/configure b/configure index 593e080..89e3f71 100755 --- 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 diff --git a/configure.in b/configure.in index 3d195c8..1d32735 100644 --- a/configure.in +++ b/configure.in @@ -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 index 0000000..e016c2b --- /dev/null +++ b/h/armhf-linux.h @@ -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 diff --git a/h/elf32_arm_reloc.h b/h/elf32_arm_reloc.h index 6a504e4..abeeac9 100644 --- a/h/elf32_arm_reloc.h +++ b/h/elf32_arm_reloc.h @@ -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; @@ -53,21 +16,21 @@ 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; diff --git a/h/elf32_arm_reloc_special.h b/h/elf32_arm_reloc_special.h index 0c3b692..9926a46 100644 --- a/h/elf32_arm_reloc_special.h +++ b/h/elf32_arm_reloc_special.h @@ -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;secsh_type==SHT_REL) for (v=v1+sec->sh_offset,ve=v+sec->sh_size,r=v;vsh_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 index 0000000..2f31665 --- /dev/null +++ b/h/elf32_armhf_reloc.h @@ -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 index 0000000..56d35a1 --- /dev/null +++ b/h/elf32_armhf_reloc_special.h @@ -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 (;psh_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;vsh_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;symst_size=0; + + for (*gs=0,sec=sec1;secsh_type==SHT_REL) + for (v=v1+sec->sh_offset,ve=v+sec->sh_size,r=v;vsh_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; + +} diff --git a/makedefc.in b/makedefc.in index a284f08..4570d09 100644 --- a/makedefc.in +++ b/makedefc.in @@ -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. diff --git a/o/unexelf.c b/o/unexelf.c index 78dc68e..9b90701 100755 --- a/o/unexelf.c +++ b/o/unexelf.c @@ -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. */