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-34) unstable; urgency=medium
 .
   * Version_2_6_13pre45
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: 2016-09-30

--- gcl-2.6.12.orig/cmpnew/gcl_cmpmain.lsp
+++ gcl-2.6.12/cmpnew/gcl_cmpmain.lsp
@@ -28,7 +28,7 @@
 
 
 (export '(*compile-print* *compile-verbose*))
-(import 'si::*tmp-dir* 'compiler)
+(import 'si::(*tmp-dir* *cc* *ld* *objdump*))
 (import 'si::*error-p* 'compiler)
 
 ;;; This had been true with Linux 1.2.13 a.out or even older
@@ -85,9 +85,8 @@
   (code result) (system (mysub (ts string) "$" "\\$"))
     (unless (and (zerop code) (zerop result))
       (cerror "Continues anyway."
-              "(SYSTEM ~S) returned a non-zero value ~D."
-              string
-              result)
+              "(SYSTEM ~S) returned a non-zero value ~D ~D."
+              string code result)
       (setq *error-p* t))
     (values result)))
 
@@ -428,8 +427,8 @@ Cannot compile ~a.~%"
 			     (si::copy-stream st *standard-output*))
 	     (with-open-file (st hn)
 			     (si::copy-stream st *standard-output*))
-	     (when (zerop (system "which objdump >/dev/null"))
-	       (safe-system (si::string-concatenate "objdump --source " (namestring on))))
+	     (when (eql (aref *objdump* 0) #\/);program found at startup in path
+	       (safe-system (si::string-concatenate *objdump* (namestring on))))
 	     (mdelete-file cn)
 	     (mdelete-file dn)
 	     (mdelete-file hn)
@@ -470,8 +469,6 @@ Cannot compile ~a.~%"
       (terpri *compiler-output2*)))))
 
 
-(defvar *cc* "cc")
-(defvar *ld* "ld")
 (defvar *ld-libs* "ld-libs")
 (defvar *opt-three* "")
 (defvar *opt-two* "")
@@ -489,7 +486,7 @@ Cannot compile ~a.~%"
     (setq na  (namestring
 	       (make-pathname :name name :type (pathname-type(first args)))))
    #+(or dos winnt)
-      (format nil "~a -I~a ~a ~a -c -w ~s -o ~s"
+      (format nil "~a -I~a ~a ~a -c -w ~a -o ~a"
 	      *cc*
 	      (concatenate 'string si::*system-directory* "../h")
 	      (if (and (boundp '*c-debug*) *c-debug*) " -g " "")
@@ -502,7 +499,7 @@ Cannot compile ~a.~%"
 	      )
 
    #-(or dos winnt)
-   (format nil  "~a -I~a ~a ~a -c ~s -o ~s ~a"
+   (format nil  "~a -I~a ~a ~a -c ~a -o ~a ~a"
 	   *cc*
 	   (concatenate 'string si::*system-directory* "../h")
 	   (if (and (boundp '*c-debug*) *c-debug*) " -g " "")
--- gcl-2.6.12.orig/h/elf32_mips_reloc_special.h
+++ gcl-2.6.12/h/elf32_mips_reloc_special.h
@@ -147,3 +147,6 @@ label_got_symbols(void *v1,Shdr *sec1,Sh
 	  (*(a_))->address=p->st_value;					\
 	  break;							\
 	}}})
+
+#undef LOAD_SYM_BY_NAME
+#define LOAD_SYM_BY_NAME(sym,st1) (!strncmp(st1+sym->st_name,"__moddi3",8))
--- gcl-2.6.12.orig/h/notcomp.h
+++ gcl-2.6.12/h/notcomp.h
@@ -361,7 +361,7 @@ extern bool writable_malloc;
 #define prof_block(x) x
 #endif
 
-#define psystem(x) prof_block(system(x))
+#define psystem(x) prof_block(vsystem(x))
 #define pfork() prof_block(fork())
 
 #include "error.h"
--- gcl-2.6.12.orig/lsp/gcl_top.lsp
+++ gcl-2.6.12/lsp/gcl_top.lsp
@@ -601,9 +601,21 @@ First directory is checked for first nam
 	     :device (pathname-device x)
 	     :directory (append (pathname-directory x) y)))))))))
 
+(defun get-path (s &aux (m (string-match "([^/ ]*)( |$)" s))(b (match-beginning 1))(e (match-end 1))
+		   (r (with-open-file (s (concatenate 'string "|which " (subseq s b e))) (read s nil 'eof))))
+  (if (eq r 'eof) s (concatenate 'string (string-downcase r) (subseq s e))))
+
+
+(defvar *cc* "cc")
+(defvar *ld* "ld")
+(defvar *objdump* "objdump --source ")
+
 (defun set-up-top-level (&aux (i (argc)) tem)
   (declare (fixnum i))
-  (setq *tmp-dir* (get-temp-dir))
+  (setq *tmp-dir* (get-temp-dir)
+	*cc* (get-path *cc*)
+	*ld* (get-path *ld*)
+	*objdump* (get-path *objdump*))
   (dotimes (j i) (push (argv j) tem))
   (setq *command-args* (nreverse tem))
   (setq tem *lib-directory*)
--- gcl-2.6.12.orig/o/file.d
+++ gcl-2.6.12/o/file.d
@@ -613,7 +613,8 @@ BEGIN:
 		else 
 		  fclose(strm->sm.sm_fp);
 		strm->sm.sm_fp = NULL;
-		if (type_of(strm->sm.sm_object0 ) == t_cons &&
+		if (strm->sm.sm_object0 &&
+		    type_of(strm->sm.sm_object0 ) == t_cons &&
 		    Mcar(strm->sm.sm_object0 ) == sSAallow_gzipped_fileA)
 		  fLdelete_file(Mcdr(strm->sm.sm_object0));
 		break;
--- gcl-2.6.12.orig/o/run_process.c
+++ gcl-2.6.12/o/run_process.c
@@ -502,6 +502,7 @@ make_socket_pair()
   stream_in->sm.sm_buffer = 0;
   stream_in->sm.sm_int0 = sockets_in[1];
   stream_in->sm.sm_int1 = 0;
+  stream_in->sm.sm_object0=stream_in->sm.sm_object1=OBJNULL;
   stream_out = (object) alloc_object(t_stream);
   stream_out->sm.sm_mode = smm_output;
   stream_out->sm.sm_fp = fp2;
@@ -510,6 +511,7 @@ make_socket_pair()
   setup_stream_buffer(stream_out);
   stream_out->sm.sm_int0 = sockets_out[1];
   stream_out->sm.sm_int1 = 0;
+  stream_out->sm.sm_object0=stream_out->sm.sm_object1=OBJNULL;
   stream = make_two_way_stream(stream_in, stream_out);
   return(stream);
 }
--- gcl-2.6.12.orig/o/sfaslelf.c
+++ gcl-2.6.12/o/sfaslelf.c
@@ -54,9 +54,10 @@ License for more details.
 
 #define ulmax(a_,b_) ({ul _a=a_,_b=b_;_a<_b ? _b : _a;})
 #define ALLOC_SEC(sec) (sec->sh_flags&SHF_ALLOC && (sec->sh_type==SHT_PROGBITS || sec->sh_type==SHT_NOBITS))
-#define  LOAD_SEC(sec) (sec->sh_flags&SHF_ALLOC &&  sec->sh_type==SHT_PROGBITS)
-#define  LOAD_SYM(sym) ({ul _b=ELF_ST_BIND(sym->st_info),_t=ELF_ST_TYPE(sym->st_info);	\
-      sym->st_value && (_b==STB_GLOBAL || _b==STB_WEAK || (_t>=STT_LOPROC && _t<=STT_HIPROC));})
+#define LOAD_SEC(sec) (sec->sh_flags&SHF_ALLOC &&  sec->sh_type==SHT_PROGBITS)
+#define LOAD_SYM_BY_BIND(sym) ({ul _b=ELF_ST_BIND(sym->st_info); sym->st_value && (_b==STB_GLOBAL || _b==STB_WEAK);})
+#define LOAD_SYM_BY_NAME(sym,st1) 0
+#define LOAD_SYM(sym,st1) (LOAD_SYM_BY_BIND(sym)||LOAD_SYM_BY_NAME(sym,st1))
 
 #define MASK(n) (~(~0ULL << (n)))
 
@@ -410,7 +411,7 @@ calc_space(ul *ns,ul *sl,Sym *sym1,Sym *
 
   for (sym=sym1;sym<syme;sym++) {
     
-    if (!LOAD_SYM(sym))
+    if (!LOAD_SYM(sym,st1))
       continue;
 
     if (d1) {
@@ -436,7 +437,7 @@ load_ptable(struct node **a,char **s,Sym
 
   for (sym=sym1;sym<syme;sym++) {
 
-    if (!LOAD_SYM(sym))
+    if (!LOAD_SYM(sym,st1))
       continue;
 
     if (d1) {
--- gcl-2.6.12.orig/o/unixsys.c
+++ gcl-2.6.12/o/unixsys.c
@@ -24,10 +24,38 @@ Foundation, 675 Mass Ave, Cambridge, MA
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-
+#include <sys/wait.h>
 
 #include "include.h"
 
+int
+vsystem(const char *command) {
+
+  unsigned j,n=strlen(command);
+  char *z=alloca(n+1),**p1,**pp,*c;
+  int s;
+  pid_t pid;
+
+  memcpy(z,command,n+1);
+  for (j=0,c=z;strtok(c," \n\t");c=NULL,j++);
+
+  memcpy(z,command,n+1);
+  p1=alloca((j+1)*sizeof(*p1));
+  for (pp=p1,c=z;(*pp=strtok(c," \n\t"));c=NULL,pp++);
+
+  if (!(pid=vfork())) {
+    execvp(*p1,p1);
+    _exit(2);
+  }
+
+  massert(pid>0);
+  massert(pid==waitpid(pid,&s,0));
+
+  return s;
+
+}
+
+
 #ifdef ATT3B2
 #include <signal.h>
 int