From: Camm Maguire Date: Tue, 25 Mar 2025 16:52:33 +0000 (-0400) Subject: X-Git-Tag: archive/raspbian/2.6.14-19+rpi1^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0ed34bf58c51cc4e8792db8598da56e2fce04f2e;p=gcl.git 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.14-10) unstable; urgency=medium * Version_2_6_15pre9 Gbp-Pq: Name Version_2_6_15pre9 --- diff --git a/configure b/configure index e2772389..1adef5b6 100755 --- a/configure +++ b/configure @@ -3042,6 +3042,7 @@ case $canonical in s390*linux*) use=s390-linux;; ia64*linux*) use=ia64-linux;; hppa*linux*) use=hppa-linux;; + loongarch64*linux*) use=loongarch64-linux;; powerpc*linux*) use=powerpc-linux;; powerpc-*-darwin*) use=powerpc-macosx;; *86*darwin*) use=386-macosx;; @@ -4664,6 +4665,9 @@ case $use in assert_arg_to_ldflags -pg GPL_FLAG="-pg" LDFLAGS=$OLD_LDFLAGS;; + loongarch64-linux) + add_arg_to_cflags -mno-relax + add_arg_to_cflags -Wa,-mno-relax;; 386-macosx) # assert_arg_to_cflags -Wno-error=implicit-function-declaration add_arg_to_cflags -Wno-incomplete-setjmp-declaration diff --git a/configure.in b/configure.in index 0c641a71..0f88f2aa 100644 --- a/configure.in +++ b/configure.in @@ -43,6 +43,7 @@ case $canonical in s390*linux*) use=s390-linux;; ia64*linux*) use=ia64-linux;; hppa*linux*) use=hppa-linux;; + loongarch64*linux*) use=loongarch64-linux;; powerpc*linux*) use=powerpc-linux;; powerpc-*-darwin*) use=powerpc-macosx;; *86*darwin*) use=386-macosx;; @@ -328,6 +329,9 @@ case $use in assert_arg_to_ldflags -pg GPL_FLAG="-pg" LDFLAGS=$OLD_LDFLAGS;; + loongarch64-linux) + add_arg_to_cflags -mno-relax + add_arg_to_cflags -Wa,-mno-relax;; 386-macosx) # assert_arg_to_cflags -Wno-error=implicit-function-declaration add_arg_to_cflags -Wno-incomplete-setjmp-declaration diff --git a/git.tag b/git.tag index 599dec87..1d2b458c 100644 --- a/git.tag +++ b/git.tag @@ -1 +1 @@ -"Version_2_6_15pre8" +"Version_2_6_15pre9" diff --git a/h/elf64_loongarch64_reloc.h b/h/elf64_loongarch64_reloc.h new file mode 100644 index 00000000..97260111 --- /dev/null +++ b/h/elf64_loongarch64_reloc.h @@ -0,0 +1,93 @@ +#define get_insn_page(x) ((x) & ~0xffful) +#define get_page_delta(dest, pc) ({ \ + ul res = get_insn_page(dest) - get_insn_page(pc); \ + if ((dest) & 0x800) \ + res += 0x1000ul - 0x100000000ul; \ + if (res & 0x80000000) \ + res += 0x100000000ul; \ + res; \ +}) +#define get_page_low(dest) ((dest) & 0xfff) +#define bdest (((long)((s+a)-p))>>2) +#define bgdest (((long)(((ul)got)-p))>>2) + + case R_LARCH_RELAX: + case R_LARCH_ALIGN: + massert(!emsg("Unsupport relaxation, please compile with '-mno-relax -Wa,-mno-relax'\n")); + break; + case R_LARCH_64: + store_val(where,~0L,(s+a)); + break; + case R_LARCH_32: + store_val(where,MASK(32),(s+a)); + break; + case R_LARCH_32_PCREL: + store_val(where,MASK(32),(s+a)-p); + break; + case R_LARCH_ADD6: + add_val(where,MASK(6),(s+a)); + break; + case R_LARCH_ADD8: + add_val(where,MASK(8),(s+a)); + break; + case R_LARCH_ADD16: + add_val(where,MASK(16),(s+a)); + break; + case R_LARCH_ADD32: + add_val(where,MASK(32),(s+a)); + break; + case R_LARCH_ADD64: + add_val(where,~0L,(s+a)); + break; + case R_LARCH_SUB6: + add_val(where,MASK(6),-(s+a)); + break; + case R_LARCH_SUB8: + add_val(where,MASK(8),-(s+a)); + break; + case R_LARCH_SUB16: + add_val(where,MASK(16),-(s+a)); + break; + case R_LARCH_SUB32: + add_val(where,MASK(32),-(s+a)); + break; + case R_LARCH_SUB64: + add_val(where,~0L,-(s+a)); + break; + case R_LARCH_B16: + store_val(where,MASK(16)<<10,bdest<<10); + break; + case R_LARCH_B21: + store_val(where,(MASK(16)<<10)|MASK(5),bdest<<10|((bdest>>16)&0x1f)); + break; + case R_LARCH_B26: + { + if ((bdest&(~MASK(25)))==0||((~bdest)&(~MASK(25)))==0) { + store_val(where,MASK(26),bdest<<10|((bdest>>16)&0x3ff)); + break; + } + if (!(sym->st_size&0x2)) + massert(!emsg("Unresolved R_LARCH_B26 symbol\n")); + got+=(sym->st_size>>2)+(sym->st_size&0x1?1:0); + store_val(where,MASK(26),bgdest<<10|((bgdest>>16)&0x3ff)); + memcpy(got,tramp,sizeof(tramp)); + store_val(got,MASK(20)<<5,(get_insn_page(s+a)-get_insn_page((ul)got))>>12<<5); + store_val((ul*)((ul)got+4),MASK(16)<<10,(((s+a)>>2)&0x3ff)<<10); + } + break; + case R_LARCH_PCALA_HI20: + store_val(where,MASK(20)<<5,get_page_delta(s+a,p)>>12<<5); + break; + case R_LARCH_PCALA_LO12: + store_val(where,MASK(12)<<10,get_page_low(s+a)<<10); + break; + case R_LARCH_GOT_PC_HI20: + got+=sym->st_size>>2; + *got=s+a; + store_val(where,MASK(20)<<5,get_page_delta((ul)got,p)>>12<<5); + break; + case R_LARCH_GOT_PC_LO12: + got+=sym->st_size>>2; + // *got=s+a; + store_val(where,MASK(12)<<10,get_page_low((ul)got)<<10); + break; diff --git a/h/elf64_loongarch64_reloc_special.h b/h/elf64_loongarch64_reloc_special.h new file mode 100644 index 00000000..50f4811e --- /dev/null +++ b/h/elf64_loongarch64_reloc_special.h @@ -0,0 +1,70 @@ +#define R_LARCH_B16 64 +#define R_LARCH_B21 65 +#define R_LARCH_B26 66 +#define R_LARCH_PCALA_HI20 71 +#define R_LARCH_PCALA_LO12 72 +#define R_LARCH_GOT_PC_HI20 75 +#define R_LARCH_GOT_PC_LO12 76 +#define R_LARCH_32_PCREL 99 +#define R_LARCH_RELAX 100 +#define R_LARCH_ALIGN 102 +#define R_LARCH_ADD6 105 +#define R_LARCH_SUB6 106 + +static unsigned int tramp[] = { + 0x1a00000c, /* pcalau12i $t0, %hi(sym) */ + 0x4c000180 /* jirl $zero, $t0, %lo(sym) */}; + +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) { + 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) { + Rela *r; + Sym *sym; + Shdr *sec; + void *v,*ve; + int idx; + const int gz = sizeof(ul)/sizeof(ul), tz = sizeof(tramp)/sizeof(ul); + massert(gz==1); + massert(tz==1); + + for (sym=sym1;symst_size=0; + + /* Count the symbols need to be fixed first. */ + for (sec=sec1;secsh_type==SHT_RELA) + 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_LARCH_GOT_PC_HI20 || + ELF_R_TYPE(r->r_info)==R_LARCH_B26 + ) { + sym=sym1+ELF_R_SYM(r->r_info); + if (ELF_R_TYPE(r->r_info)==R_LARCH_B26 && LOCAL_SYM(sym)) + continue; + + if (ELF_R_TYPE(r->r_info)==R_LARCH_GOT_PC_HI20) + sym->st_size|=0x1; + if (ELF_R_TYPE(r->r_info)==R_LARCH_B26) + sym->st_size|=0x2; + } + + for (idx=0,sym=sym1;symst_size==0) + continue; + massert(!(sym->st_size>>2)); + sym->st_size|=idx<<2; + if (sym->st_size&0x1) + idx+=gz; + if (sym->st_size&0x2) + idx+=tz; + } + + *gs=idx; + return 0; +} diff --git a/h/loongarch64-linux.h b/h/loongarch64-linux.h new file mode 100644 index 00000000..d50065ae --- /dev/null +++ b/h/loongarch64-linux.h @@ -0,0 +1,27 @@ +#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 +#endif + +/*#define NULL_OR_ON_C_STACK(x) ((x)==0 || ((unsigned int)x) > (unsigned int)(pagetochar(MAXPAGE+1)))*/ + +/* #define ADDITIONAL_FEATURES \ */ +/* ADD_FEATURE("BSD386"); \ */ +/* ADD_FEATURE("MC68020") */ + + +/* #define I386 */ +#define SGC + +/* Apparently stack pointers can be 4 byte aligned, at least &argc -- CM */ +#define C_GC_OFFSET 4 + +#define RELOC_H "elf64_loongarch64_reloc.h" +#define SPECIAL_RELOC_H "elf64_loongarch64_reloc_special.h" +/* #define MAX_CODE_ADDRESS (1L<<31)/\*large memory model broken gcc 4.8*\/ */ + +#define NEED_STACK_CHK_GUARD diff --git a/o/gmp_big.c b/o/gmp_big.c index ddcb41e5..ff2ee55c 100755 --- a/o/gmp_big.c +++ b/o/gmp_big.c @@ -292,54 +292,52 @@ big_minus(object x) #endif -static int -double_exponent(double d) { +/* static int */ +/* double_exponent(double d) { */ - union {double d;int i[2];} u; +/* union {double d;int i[2];} u; */ - if (d == 0.0) - return(0); +/* if (d == 0.0) */ +/* return(0); */ - u.d=d; - return (((u.i[HIND] & 0x7ff00000) >> 20) - 1022); +/* u.d=d; */ +/* return (((u.i[HIND] & 0x7ff00000) >> 20) - 1022); */ -} +/* } */ -static double -set_exponent(double d, int e) { +/* static double */ +/* set_exponent(double d, int e) { */ - union {double d;int i[2];} u; +/* union {double d;int i[2];} u; */ - if (d == 0.0) - return(0.0); +/* if (d == 0.0) */ +/* return(0.0); */ - u.d=d; - u.i[HIND]= (u.i[HIND] & 0x800fffff) | (((e + 1022) << 20) & 0x7ff00000); - return(u.d); +/* u.d=d; */ +/* u.i[HIND]= (u.i[HIND] & 0x800fffff) | (((e + 1022) << 20) & 0x7ff00000); */ +/* return(u.d); */ -} +/* } */ double big_to_double(object x) { - double d=mpz_get_d(MP(x)); - int s=mpz_sizeinbase(MP(x),2); - if (s>=54 && mpz_tstbit(MP(x),s-54)) { - - union {double d;int i[2];} u; - - u.i[HIND]=0; - u.i[LIND]=1; - - d+=(d>0.0 ? 1.0 : -1.0)*set_exponent(u.d,double_exponent(d)-53); + int s=mpz_sizeinbase(MP(x),2),i=0,j; + if (s>=54 && mpz_tstbit(MP(x),s-54)) + for (i=mpz_tstbit(MP(x),s-53),j=s-55;!i && j>=0 && !(i=mpz_tstbit(MP(x),j));j--); + + if (i) { + mpz_set_si(MP(big_fixnum1),mpz_sgn(MP(x))>0 ? 1 : -1); + mpz_mul_2exp(MP(big_fixnum1),MP(big_fixnum1),s-54); + mpz_add(MP(big_fixnum1),MP(big_fixnum1),MP(x)); + x=big_fixnum1; } - return d; + return mpz_get_d(MP(x)); } - /* static object copy_big(object x) */ /* { */ /* if (type_of(x)==t_bignum) */