From 979ae8b7cd60e0a00338df83728cc5c237f786cf Mon Sep 17 00:00:00 2001 From: Camm Maguire Date: Sun, 13 Nov 2022 12:55:14 +0000 Subject: [PATCH] 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-48) unstable; urgency=medium * list_order.1 Gbp-Pq: Name list_order.5 --- configure | 1 + configure.in | 1 + h/elf64_mips_reloc.h | 28 ++++++++---------------- h/elf64_mips_reloc_special.h | 42 ++++++++++++++++++++++++------------ h/pool.h | 15 ++++++------- 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/configure b/configure index da90182..f58a1df 100755 --- a/configure +++ b/configure @@ -4188,6 +4188,7 @@ case $use in mips*) case $canonical in mips64*linux*) +# assert_arg_to_cflags -mxgot assert_arg_to_ldflags -Wl,-z,now;; esac ;; diff --git a/configure.in b/configure.in index bdb3630..6e0d6f2 100644 --- a/configure.in +++ b/configure.in @@ -389,6 +389,7 @@ case $use in mips*) case $canonical in mips64*linux*) +# assert_arg_to_cflags -mxgot assert_arg_to_ldflags -Wl,-z,now;; esac ;; diff --git a/h/elf64_mips_reloc.h b/h/elf64_mips_reloc.h index 784ba9f..0ab0040 100644 --- a/h/elf64_mips_reloc.h +++ b/h/elf64_mips_reloc.h @@ -32,23 +32,14 @@ if (s>=ggot && sr_addend=((void *)gote-(void *)got)-s; - switch(tp) { - case R_MIPS_GOT_HI16: - case R_MIPS_CALL_HI16: - r->r_info=((ul)R_MIPS_HI16<<56)|(r->r_info&MASK(32)); - relocate(sym1,r,((Rela *)r)->r_addend,start,got,gote); - break; - case R_MIPS_GOT_LO16: - case R_MIPS_CALL_LO16: - r->r_info=((ul)R_MIPS_LO16<<56)|(r->r_info&MASK(32)); - relocate(sym1,r,((Rela *)r)->r_addend,start,got,gote); - break; - default: - store_val(where,MASK(16),((void *)gote-(void *)got)); - break; - } + *gote=s+(MIPS_HIGH(a)<<16); + a=(void *)gote-(void *)got; + if (tp==R_MIPS_GOT_HI16||tp==R_MIPS_CALL_HI16) + a=MIPS_HIGH(a); + else if (tp==R_MIPS_GOT_LO16||tp==R_MIPS_CALL_LO16) + a&=MASK(16); + massert(!(a&~MASK(16))); + store_val(where,MASK(16),a); break; case R_MIPS_GOT_OFST: recurse(s+a); @@ -63,8 +54,7 @@ case R_MIPS_LO16: recurse(s+a); s+=a; - a=*where&MASK(16); - if (a&0x8000) a|=0xffffffffffff0000; + a=(short)*where; a+=s&MASK(16); a+=(a&0x8000)<<1; store_val(where,MASK(16),a); diff --git a/h/elf64_mips_reloc_special.h b/h/elf64_mips_reloc_special.h index 4c6ec7e..0e63d74 100644 --- a/h/elf64_mips_reloc_special.h +++ b/h/elf64_mips_reloc_special.h @@ -16,6 +16,7 @@ static ul ggot,ggote,la; static Rela *hr,*lr; #undef ELF_R_TYPE #define ELF_R_TYPE(a_) ELF_R_TYPE1(a_) +#define MIPS_HIGH(a_) ({ul _a=(a_);(_a-(short)_a)>>16;}) typedef struct { ul entry,gotoff; @@ -98,12 +99,12 @@ label_got_symbols(void *v1,Shdr *sec1,Shdr *sece,Sym *sym1,Sym *syme,const char Sym *sym; Shdr *sec; void *v,*ve; - ul q=0,a,b; + ul a,b; for (sym=sym1;symst_size=0; + sym->st_other=sym->st_size=0; - for (*gs=0,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_MIPS_CALL16|| @@ -116,24 +117,37 @@ label_got_symbols(void *v1,Shdr *sec1,Shdr *sece,Sym *sym1,Sym *syme,const char sym=sym1+ELF_R_SYM(r->r_info); - a=r->r_addend>>15; + /*unlikely to save got space by recording possible holes in addend range*/ + if ((a=MIPS_HIGH(r->r_addend)+1)>sym->st_other) + sym->st_other=a; + + } - if (2*a>=sizeof(sym->st_size) || !((sym->st_size>>(a*16))&0xffff)) { + for (*gs=0,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_MIPS_CALL16|| + ELF_R_TYPE(r->r_info)==R_MIPS_GOT_DISP|| + ELF_R_TYPE(r->r_info)==R_MIPS_GOT_HI16|| + ELF_R_TYPE(r->r_info)==R_MIPS_GOT_LO16|| + ELF_R_TYPE(r->r_info)==R_MIPS_CALL_HI16|| + ELF_R_TYPE(r->r_info)==R_MIPS_CALL_LO16|| + ELF_R_TYPE(r->r_info)==R_MIPS_GOT_PAGE) { - q=++*gs; - if (2*ast_size)) { - massert(q<=0xffff); - sym->st_size|=(q<<(a*16)); - } - - massert(!make_got_room_for_stub(sec1,sece,sym,st1,gs)); + sym=sym1+ELF_R_SYM(r->r_info); + if (sym->st_other) { + sym->st_size=++*gs; + if (sym->st_other>1) + (*gs)+=sym->st_other-1; + else + massert(!make_got_room_for_stub(sec1,sece,sym,st1,gs)); + sym->st_other=0; } b=sizeof(r->r_addend)*4; massert(!(r->r_addend>>b)); - q=2*a>=sizeof(sym->st_size) ? q : (sym->st_size>>(a*16))&0xffff; - r->r_addend|=(q<<=b); + r->r_addend|=((sym->st_size+MIPS_HIGH(r->r_addend))<s=0; unlock_pool(); - f.l_type=F_UNLCK; - massert(!fcntl(pool,F_SETLK,&f)); - - fprintf(stderr,"Initializing pool\n"); - fflush(stderr); - } f.l_type=F_RDLCK; - massert(!fcntl(pool,F_SETLK,&f)); + plp=&f; + massert(!set_lock()); + + plp=&pl; register_pool(1); massert(!atexit(close_pool)); -- 2.30.2