Blob Blame Raw
Description: <short summary of the 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-74) unstable; urgency=medium
 .
   * Version_2_6_13pre63
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-03-21

--- gcl-2.6.12.orig/h/elf64_alpha_reloc.h
+++ gcl-2.6.12/h/elf64_alpha_reloc.h
@@ -1,16 +1,14 @@
     case R_ALPHA_GPDISP:
-      s=(ul)got;
-      s-=p; 
-      s+=(s&0x8000)<<1;
-      store_val(where,MASK(16),s>>16); 
-      where=(void *)where+a; 
-      store_val(where,MASK(16),s); 
+      gotoff=(ul)(got+(a>>32));
+      s=gotoff-p;
+      store_val(where,MASK(16),(s-(short)s)>>16);
+      store_val((void *)where+(a&MASK(32)),MASK(16),s);
       break;
     case R_ALPHA_SREL32:
       store_val(where,MASK(32),s+a-p);
       break;
     case R_ALPHA_GPREL32:
-      store_val(where,MASK(32),s+a-(ul)got);
+      store_val(where,MASK(32),s+a-gotoff);
       break;
     case R_ALPHA_LITUSE:
     case R_ALPHA_HINT:
@@ -22,23 +20,20 @@
       store_val(where,MASK(32),s+a);
       break;
     case R_ALPHA_LITERAL:
-      massert(a || sym->st_size);
-      gote=got+(a ? (a>>32) : sym->st_size)-1;
+      s+=a&MASK(32);
+      a=(a>>32)-1;
       if (s>=ggot1 && s<ggote) {
-        massert(!write_stub(s,got,gote));
+        massert(!write_stub(s,(ul *)gotoff,got+a));
       } else 
-	*gote=s+(a&MASK(32));
-      s=(gote-got)*sizeof(*got);
-      massert(!(s&~MASK(15)));
-      store_val(where,MASK(16),s);
+        got[a]=s;
+      store_vals(where,MASK(16),(ul)(got+a)-gotoff);
       break;
     case R_ALPHA_GPRELHIGH:
-      s+=a-(ul)got;
-      s+=(s&0x8000)<<1;      
-      store_val(where,MASK(16),s>>16);
+      s+=a-gotoff;
+      store_val(where,MASK(16),(s-(short)s)>>16);
       break;
     case R_ALPHA_GPRELLOW:
-      store_val(where,MASK(16),s+a-(ul)got);
+      store_val(where,MASK(16),s+a-gotoff);
       break;
     case R_ALPHA_TLS_GD_HI:
       store_vals(where,MASK(21),((long)(s+a-(p+4)))>>2);
--- gcl-2.6.12.orig/h/elf64_alpha_reloc_special.h
+++ gcl-2.6.12/h/elf64_alpha_reloc_special.h
@@ -1,4 +1,4 @@
-static ul ggot1,ggote;
+static ul ggot1,ggote,gotoff;
 
 static int
 write_stub(ul s,ul *got,ul *gote) {
@@ -61,44 +61,60 @@ find_special_params(void *v,Shdr *sec1,S
 static int
 label_got_symbols(void *v1,Shdr *sec1,Shdr *sece,Sym *sym1,Sym *syme,const char *st1,const char *sn,ul *gs) {
 
-  Sym *sym;
-  Rela *r,*rr;
+  Sym *sym,*fsym=sym1;
+  Rela *r;
   Shdr *sec;
-  void *v,*ve,*vv;
-  ul q;
+  void *v,*ve;
+  ul q,gotp;
 
   for (sym=sym1;sym<syme;sym++)
     sym->st_size=0;
 
-  for (*gs=0,sec=sec1;sec<sece;sec++)
-    if (sec->sh_type==SHT_RELA || sec->sh_type==SHT_REL)
+  for (*gs=gotp=0,sec=sec1;sec<sece;sec++)
+    if (sec->sh_type==SHT_RELA)
       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_ALPHA_LITERAL) {
+	switch(ELF_R_TYPE(r->r_info)) {
+
+	case R_ALPHA_LITERAL:
 
-	  if (sec->sh_type!=SHT_RELA || !r->r_addend) {
+	  if (!r->r_addend) {
 
 	    sym=sym1+ELF_R_SYM(r->r_info);
+	    q=(gotp-sym->st_size)*sizeof(*gs);
 
-	    if (!sym->st_size) {
+	    if (!sym->st_size || q!=(short)q) {
 	      sym->st_size=++*gs;
 	      massert(!make_got_room_for_stub(sec1,sece,sym,st1,gs));
 	    }
 
-	  } else {
+	    q=sym->st_size;
+
+	  } else
+
+	    q=++*gs;
+
+	  massert(!(r->r_addend>>32));
+	  r->r_addend|=(q<<32);
 
-	    for (rr=vv=v-sec->sh_entsize;
-		 vv>=v1 && (ELF_R_TYPE(rr->r_info)!=ELF_R_TYPE(r->r_info) ||
-			    ELF_R_SYM(rr->r_info)!=ELF_R_SYM(r->r_info) ||
-			    rr->r_addend!=r->r_addend);
-		 vv-=sec->sh_entsize,rr=vv);
-
-	    q=vv<v1 ? ++*gs : rr->r_addend>>32;
-	    massert(!(r->r_addend>>32));
-	    r->r_addend|=(q<<32);
+	  q=(q-gotp)*sizeof(*gs);
+	  massert(q==(short)q);
 
+	  break;
+
+	case R_ALPHA_GPDISP:
+
+	  for (sym=fsym;sym<syme && (sym->st_shndx!=1 || sym->st_value!=r->r_offset);sym++);
+
+	  if (sym<syme) {
+	    fsym=sym;
+	    gotp=*gs+1;
 	  }
 
+	  r->r_addend|=(gotp<<32);
+
+	  break;
+
 	}
 
   return 0;