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-72) unstable; urgency=medium
 .
   * Version_2_6_13pre61
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-14

--- gcl-2.6.12.orig/h/elf64_alpha_reloc.h
+++ gcl-2.6.12/h/elf64_alpha_reloc.h
@@ -22,12 +22,12 @@
       store_val(where,MASK(32),s+a);
       break;
     case R_ALPHA_LITERAL:
-      gote=got+(a>>32)-1;
-      a&=MASK(32);
+      massert(a || sym->st_size);
+      gote=got+(a ? (a>>32) : sym->st_size)-1;
       if (s>=ggot1 && s<ggote) {
         massert(!write_stub(s,got,gote));
       } else 
-	*gote=s+a;
+	*gote=s+(a&MASK(32));
       s=(gote-got)*sizeof(*got);
       massert(!(s&~MASK(15)));
       store_val(where,MASK(16),s);
--- gcl-2.6.12.orig/h/elf64_alpha_reloc_special.h
+++ gcl-2.6.12/h/elf64_alpha_reloc_special.h
@@ -61,36 +61,45 @@ 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;
   Shdr *sec;
   void *v,*ve,*vv;
-  ul b,q;
+  ul q;
+
+  for (sym=sym1;sym<syme;sym++)
+    sym->st_size=0;
 
   for (*gs=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) {
-
-	  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);
-
-	  b=sizeof(r->r_addend)*4;
-	  if (vv>=v1)
-	    q=rr->r_addend>>b;
-	  else {
-	    q=++*gs;
-	    massert(!make_got_room_for_stub(sec1,sece,sym1+ELF_R_SYM(r->r_info),st1,gs));
+    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) {
+
+	if (sec->sh_type!=SHT_RELA || !r->r_addend) {
+
+	  sym=sym1+ELF_R_SYM(r->r_info);
+
+	  if (!sym->st_size) {
+	    sym->st_size=++*gs;
+	    massert(!make_got_room_for_stub(sec1,sece,sym,st1,gs));
 	  }
-	  massert(*gs==q || !r->r_addend);
-	  massert(!(r->r_addend>>b));
-	  r->r_addend|=(q<<b);
+
+	} else {
+
+	    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);
 
 	}
-  
+
+      }
+
   return 0;
   
 }