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.7+dfsga-33) unstable; urgency=high
 .
   * fix mark_link_array for marked sLAlink_arrayA->s.s_dbind
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: http://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.7+dfsga.orig/configure
+++ gcl-2.6.7+dfsga/configure
@@ -4296,14 +4296,14 @@ case $use in
 #			if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 			;;
 		mips*)
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.6.2
 			;;
 		ia64*)
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
 			;;
 		arm*)
 			TCFLAGS="$TCFLAGS -mlong-calls -fdollars-in-identifiers -g "
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
 #			if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 			;;
 		powerpc*)
--- gcl-2.6.7+dfsga.orig/configure.in
+++ gcl-2.6.7+dfsga/configure.in
@@ -577,14 +577,14 @@ case $use in
 #			if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 			;;
 		mips*)
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.6.2
 			;;
 		ia64*)
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
 			;;
 		arm*)
 			TCFLAGS="$TCFLAGS -mlong-calls -fdollars-in-identifiers -g "
-			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
+#			if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
 #			if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 			;;
 		powerpc*) 
--- gcl-2.6.7+dfsga.orig/o/main.c
+++ gcl-2.6.7+dfsga/o/main.c
@@ -1097,14 +1097,12 @@ FFN(siLsave_system)(void) {
   saving_system = TRUE;
   {
 
-    void *old_rb_end=rb_end,*old_rb_limit=rb_limit;
     fixnum old_nrbpage=nrbpage;
 
     /* add_pages(tm_table+t_contiguous,1);/\*ensure at least one free contiguous page for starup mallocs*\/ */
     minimize_image();
 
-    rb_end=old_rb_end;
-    rb_limit=old_rb_limit;
+    rb_limit=rb_end=REAL_RB_START+old_nrbpage*PAGESIZE;
     set_tm_maxpage(tm_table+t_relocatable,old_nrbpage);
 
   }
--- gcl-2.6.7+dfsga.orig/o/gbc.c
+++ gcl-2.6.7+dfsga/o/gbc.c
@@ -244,10 +244,15 @@ mark_link_array(void *v,void *ve) {
 
   if (sLAlink_arrayA->s.s_dbind==Cnil)
     return;
+
   p=(void *)sLAlink_arrayA->s.s_dbind->v.v_self;
   pe=(void *)p+sLAlink_arrayA->s.s_dbind->v.v_fillp;
 
-  if (is_marked(sLAlink_arrayA->s.s_dbind)) {
+  if (is_marked(sLAlink_arrayA->s.s_dbind)
+#ifdef SGC
+      && (!sgc_enabled || SGC_RELBLOCK_P(sLAlink_arrayA->s.s_dbind->v.v_self))
+#endif
+      ) {
     fixnum j=rb_pointer1-rb_pointer;
     p=(void *)p+j;
     pe=(void *)pe+j;
@@ -257,7 +262,7 @@ mark_link_array(void *v,void *ve) {
     if (*p>=v && *p<ve) {
       massert(!LINK_ARRAY_MARKED(p));
 #ifdef SGC
-      if(sgc_enabled && SGC_RELBLOCK_P(p))
+      if(!sgc_enabled || IS_WRITABLE(page(p)))
 #endif
 	MARK_LINK_ARRAY(p);
     }
