Blob Blame History 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-17) unstable; urgency=medium
 .
   * Version_2_6_13pre20
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: <YYYY-MM-DD>

--- gcl-2.6.12.orig/configure
+++ gcl-2.6.12/configure
@@ -6553,6 +6553,7 @@ else
 
         #include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "./h/enum.h"
 	#define OBJ_ALIGN
@@ -6681,6 +6682,7 @@ else
 /* end confdefs.h.  */
 #include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "h/enum.h"
 	#include "h/type.h"
@@ -6710,6 +6712,7 @@ else
 /* end confdefs.h.  */
 #include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "`pwd`/h/enum.h"
 	#include "`pwd`/h/type.h"
--- gcl-2.6.12.orig/configure.in
+++ gcl-2.6.12/configure.in
@@ -1301,6 +1301,7 @@ AC_MSG_CHECKING([for required object ali
 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
         #include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "./h/enum.h"
 	#define OBJ_ALIGN
@@ -1341,6 +1342,7 @@ AC_MSG_CHECKING(sizeof struct contblock)
 if test "$use" = "mingw" ; then
 AC_TRY_RUN([#include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "h/enum.h"
 	#include "h/type.h"
@@ -1357,6 +1359,7 @@ AC_TRY_RUN([#include <stdio.h>
 else
 AC_TRY_RUN([#include <stdio.h>
 	#define EXTER
+	#define INLINE
 	#include "$MP_INCLUDE"
 	#include "`pwd`/h/enum.h"
 	#include "`pwd`/h/type.h"
--- gcl-2.6.12.orig/gcl-tk/guis.h
+++ gcl-2.6.12/gcl-tk/guis.h
@@ -7,6 +7,7 @@
 #define IMMNUM_H
 #define GMP_WRAPPERS_H
 #define ERROR_H
+#undef INLINE
 
 #include "include.h"
 
--- gcl-2.6.12.orig/h/elf64_mips_reloc.h
+++ gcl-2.6.12/h/elf64_mips_reloc.h
@@ -15,7 +15,10 @@
       gote=got+(a>>32)-1;
       a&=MASK(32);
       store_val(where,MASK(16),((void *)gote-(void *)got));
-      *gote=s+(a&~MASK(16))+((a&0x8000)<<1);
+      if (s>=ggot && s<ggote) {
+        massert(!write_stub(s,got,gote));
+      } else
+        *gote=s+(a&~MASK(16))+((a&0x8000)<<1);
       break;
     case R_MIPS_GOT_OFST:
       store_val(where,MASK(16),a);
--- gcl-2.6.12.orig/h/elf64_mips_reloc_special.h
+++ gcl-2.6.12/h/elf64_mips_reloc_special.h
@@ -1,4 +1,4 @@
-static Rela *hr;
+static ul ggot,ggote; static Rela *hr;
 
 #undef ELF_R_SYM 
 #define ELF_R_SYM(a_) (a_&0xffffffff) 
@@ -7,9 +7,66 @@ static Rela *hr;
 #define ELF_R_FTYPE(a_) ((a_>>56)&0xff)
 
 static int
+write_stub(ul s,ul *got,ul *gote) {
+
+  int *goti;
+
+  *gote=(ul)(goti=(void *)(gote+2));
+  *++gote=s;
+  s=((void *)gote-(void *)got);
+  *goti++=(0x37<<26)|(0x1c<<21)|(0x19<<16)|s;
+  *goti++=(0x37<<26)|(0x19<<21)|(0x19<<16)|0;
+  *goti++=0x03200008;
+  *goti++=0x00200825;
+
+  return 0;
+
+}
+
+static int
+make_got_room_for_stub(Shdr *sec1,Shdr *sece,Sym *sym,const char *st1,ul *gs) {
+
+  Shdr *ssec=sec1+sym->st_shndx;
+  struct node *a;
+  if ((ssec>=sece || !ALLOC_SEC(ssec)) &&
+      (a=find_sym_ptable(st1+sym->st_name)) &&
+      a->address>=ggot && a->address<ggote)
+    (*gs)+=3;
+
+  return 0;
+
+}
+
+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) {
   
+  Shdr *sec;
+  ul *q,gotsym=0,locgotno=0,stub,stube;
+  void *p,*pe;
+
+  massert(sec=get_section(".dynamic",sec1,sece,sn));
+  for (p=(void *)sec->sh_addr,pe=p+sec->sh_size;p<pe;p+=sec->sh_entsize) {
+    q=p;
+    if (q[0]==DT_MIPS_GOTSYM)
+      gotsym=q[1];
+    if (q[0]==DT_MIPS_LOCAL_GOTNO)
+      locgotno=q[1];
+  }
+  massert(gotsym && locgotno);
+
+  massert(sec=get_section(".MIPS.stubs",sec1,sece,sn));
+  stub=sec->sh_addr;
+  stube=sec->sh_addr+sec->sh_size;
+
+  massert(sec=get_section(".got",sec1,sece,sn));
+  ggot=sec->sh_addr+locgotno*sec->sh_entsize;
+  ggote=sec->sh_addr+sec->sh_size;
+
+  for (ds1+=gotsym,sym=ds1;sym<dse;sym++)
+    if (!sym->st_value || (sym->st_value>=stub && sym->st_value<stube))
+      sym->st_value=ggot+(sym-ds1)*sec->sh_entsize;
+
   return 0;
 
 }
@@ -45,6 +102,8 @@ label_got_symbols(void *v1,Shdr *sec1,Sh
 	      sym->st_size|=(q<<(a*16));
 	    }
 	    
+	    massert(!make_got_room_for_stub(sec1,sece,sym,st1,gs));
+
 	  }
 
 	  b=sizeof(r->r_addend)*4; 
--- gcl-2.6.12.orig/h/notcomp.h
+++ gcl-2.6.12/h/notcomp.h
@@ -364,3 +364,13 @@ extern bool writable_malloc;
 #define pfork() prof_block(fork())
 
 #include "error.h"
+
+#if __GNU_MP_VERSION > 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR >= 2)
+extern void __gmp_randget_mt ();
+extern void __gmp_randclear_mt ();
+extern void __gmp_randiset_mt ();
+
+typedef struct {void *a,*b,*c,*d;} gmp_randfnptr_t;
+EXTER gmp_randfnptr_t Mersenne_Twister_Generator_Noseed;
+#endif
+
--- gcl-2.6.12.orig/h/object.h
+++ gcl-2.6.12/h/object.h
@@ -349,11 +349,7 @@ EXTER char *new_rb_start;		/*  desired r
 EXTER char *rb_start;           	/*  relblock start  */
 EXTER char *rb_end;			/*  relblock end  */
 EXTER char *rb_limit;			/*  relblock limit  */
-EXTER char *rb_pointer;		/*  relblock pointer  */
-
-#ifndef INLINE
-#define INLINE
-#endif
+EXTER char *rb_pointer;                 /*  relblock pointer  */
 
 INLINE ufixnum
 rb_size(void) {
--- gcl-2.6.12.orig/o/big.c
+++ gcl-2.6.12/o/big.c
@@ -70,6 +70,32 @@ DEFUN_NEW("SET-GMP-ALLOCATE-RELOCATABLE"
   RETURN1(flag);
 }
 
+#ifndef GMP_USE_MALLOC
+object big_gcprotect;
+object big_fixnum1;
+
+#include "gmp.c"
+
+void
+gcl_init_big1(void) {
+
+  mp_set_memory_functions( gcl_gmp_alloc,gcl_gmp_realloc,gcl_gmp_free);
+  jmp_gmp=0;
+
+#if __GNU_MP_VERSION > 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR >= 2)
+  Mersenne_Twister_Generator_Noseed.b=__gmp_randget_mt;
+  Mersenne_Twister_Generator_Noseed.c=__gmp_randclear_mt;
+  Mersenne_Twister_Generator_Noseed.d=__gmp_randiset_mt;
+#endif
+
+}
+
+#else
+gcl_init_big1()
+{
+}
+#endif
+
 #ifdef GMP
 #include "gmp_big.c"
 #else
@@ -93,7 +119,6 @@ void zero_big(object x)
   ZERO_BIG(x);
 }
 
-
 #ifndef HAVE_MP_COERCE_TO_STRING
 
 double digitsPerBit[37]={ 0,0,
--- gcl-2.6.12.orig/o/gmp_big.c
+++ gcl-2.6.12/o/gmp_big.c
@@ -81,27 +81,6 @@ static object verify_big_or_zero(object
 #define verify_big_or_zero(x)
 #endif
 
-
- 
-
-
-#ifndef GMP_USE_MALLOC
-object big_gcprotect;
-object big_fixnum1;
-
-#include "gmp.c"
-void
-gcl_init_big1(void) {
-    mp_set_memory_functions( gcl_gmp_alloc,gcl_gmp_realloc,gcl_gmp_free);
-    jmp_gmp=0;
-}
-
-#else
-gcl_init_big1()
-{
-}
-#endif  
-
 object
 new_bignum(void)
 { object ans;
--- gcl-2.6.12.orig/o/main.c
+++ gcl-2.6.12/o/main.c
@@ -511,9 +511,7 @@ main(int argc, char **argv, char **envp)
 
     terminal_io->sm.sm_object0->sm.sm_fp = stdin;
     terminal_io->sm.sm_object1->sm.sm_fp = stdout;
-#ifdef LD_BIND_NOW /*FIXME currently mips only, verify that these two requirements are the same*/
-    reinit_gmp();
-#endif
+
     gcl_init_big1();
 #ifdef HAVE_READLINE
     gcl_init_readline_function();
--- gcl-2.6.12.orig/o/num_rand.c
+++ gcl-2.6.12/o/num_rand.c
@@ -104,34 +104,6 @@ trap_gcl_gmp_allocfun(size_t size){
 }
 #endif
 
-#if __GNU_MP_VERSION > 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR >= 2)
-extern void
-__gmp_randget_mt ();
-extern void
-__gmp_randclear_mt ();
-extern void
-__gmp_randiset_mt ();
-
-typedef struct {void *a,*b,*c,*d;} gmp_randfnptr_t;
-static gmp_randfnptr_t Mersenne_Twister_Generator_Noseed = {
-  NULL,
-  __gmp_randget_mt,
-  __gmp_randclear_mt,
-  __gmp_randiset_mt
-};
-#endif
-
-void
-reinit_gmp() {
-
-#if __GNU_MP_VERSION > 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR >= 2)
-  Mersenne_Twister_Generator_Noseed.b=__gmp_randget_mt;
-  Mersenne_Twister_Generator_Noseed.c=__gmp_randclear_mt;
-  Mersenne_Twister_Generator_Noseed.d=__gmp_randiset_mt;
-#endif
-
-}
-
 void
 init_gmp_rnd_state(__gmp_randstate_struct *x) {
 
--- gcl-2.6.12.orig/unixport/sys_init.lsp.in
+++ gcl-2.6.12/unixport/sys_init.lsp.in
@@ -66,9 +66,7 @@
       *opt-two* @LI-OPT-TWO@
       *init-lsp* @LI-INIT-LSP@)
 
-(import 'si::(clines defentry defcfun object void int double
-		     quit bye gbc system commonp
-		     *break-on-warnings*
+(import 'si::(commonp *break-on-warnings*
 		     make-char char-bits char-font char-bit set-char-bit string-char-p int-char
 		     char-font-limit char-bits-limit char-control-bit
 		     char-meta-bit char-super-bit char-hyper-bit compiler-let) :cltl1-compat)
@@ -79,3 +77,4 @@
 #-ansi-cl(do-symbols (s :cltl1-compat) (export s :lisp)))
 
 #+ansi-cl (use-package :pcl :user)
+(import 'si::(clines defentry defcfun object void int double quit bye gbc system) :user)