385abae
Description: <short summary of the patch>
385abae
 TODO: Put a short summary on the line above and replace this paragraph
385abae
 with a longer explanation of this change. Complete the meta-information
385abae
 with other relevant fields (see below for details). To make it easier, the
385abae
 information below has been extracted from the changelog. Adjust it or drop
385abae
 it.
385abae
 .
385abae
 gcl (2.6.12-31) unstable; urgency=medium
385abae
 .
385abae
   * Version_2_6_13pre39
385abae
Author: Camm Maguire <camm@debian.org>
385abae
385abae
---
385abae
The information above should follow the Patch Tagging Guidelines, please
385abae
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
385abae
are templates for supplementary fields that you might want to add:
385abae
385abae
Origin: <vendor|upstream|other>, <url of original patch>
385abae
Bug: <url in upstream bugtracker>
385abae
Bug-Debian: https://bugs.debian.org/<bugnumber>
385abae
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
385abae
Forwarded: <no|not-needed|url proving that it has been forwarded>
385abae
Reviewed-By: <name and email of someone who approved the patch>
385abae
Last-Update: <YYYY-MM-DD>
385abae
385abae
--- gcl-2.6.12.orig/o/unexelf.c
385abae
+++ gcl-2.6.12/o/unexelf.c
385abae
@@ -428,6 +428,8 @@ extern void fatal (char *, ...);
385abae
 #include <syms.h> /* for HDRR declaration */
385abae
 #endif /* __sgi */
385abae
 
385abae
+#include "page.h"
385abae
+
385abae
 #ifndef MAP_ANON
385abae
 #ifdef MAP_ANONYMOUS
385abae
 #define MAP_ANON MAP_ANONYMOUS
385abae
@@ -655,7 +657,7 @@ unexec (char *new_name, char *old_name,
385abae
   char *old_section_names;
385abae
 
385abae
   ElfW(Addr) old_bss_addr, new_bss_addr,new_data2_addr;
385abae
-  ElfW(Off)  old_bss_size, new_data2_size,old_bss_offset,new_data2_offset,old_file_size,new_file_size;
385abae
+  ElfW(Off)  old_bss_size, new_data2_size,old_bss_offset,new_data2_offset,old_file_size,new_file_size,data_bss_offset;
385abae
 
385abae
   int n, nn;
385abae
   int old_bss_index, old_sbss_index;
385abae
@@ -772,7 +774,9 @@ unexec (char *new_name, char *old_name,
385abae
   if (new_file < 0)
385abae
     fatal ("Can't creat (%s): errno %d\n", new_name, errno);
385abae
 
385abae
-  new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size + (new_data2_offset-old_bss_offset);
385abae
+  data_bss_offset=CEI(new_data2_offset-old_bss_offset,sizeof(long));/*????, e.g. sparc64*/
385abae
+
385abae
+  new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size + data_bss_offset;
385abae
 
385abae
   if (ftruncate (new_file, new_file_size))
385abae
     fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
385abae
@@ -784,7 +788,7 @@ unexec (char *new_name, char *old_name,
385abae
   new_file_h = (ElfW(Ehdr) *) new_base;
385abae
   new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff);
385abae
   new_section_h = (ElfW(Shdr) *)
385abae
-    ((byte *) new_base + old_file_h->e_shoff + new_data2_size + (new_data2_offset-old_bss_offset));
385abae
+    ((byte *) new_base + old_file_h->e_shoff + new_data2_size + data_bss_offset);
385abae
 
385abae
 
385abae
   /* Make our new file, program and section headers as copies of the
385abae
@@ -802,7 +806,7 @@ unexec (char *new_name, char *old_name,
385abae
    * further away now.
385abae
    */
385abae
 
385abae
-  new_file_h->e_shoff += new_data2_size + (new_data2_offset-old_bss_offset);
385abae
+  new_file_h->e_shoff += new_data2_size + data_bss_offset;
385abae
   new_file_h->e_shnum += 1;
385abae
 
385abae
 #ifdef DEBUG
385abae
@@ -958,7 +962,7 @@ unexec (char *new_name, char *old_name,
385abae
 	  if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset ||
385abae
 	      /* solaris has symtab straddling bss offset */
385abae
 	      NEW_SECTION_H (nn).sh_offset+NEW_SECTION_H (nn).sh_size > old_bss_offset)
385abae
-	    NEW_SECTION_H (nn).sh_offset += new_data2_size+(new_data2_offset-old_bss_offset);
385abae
+	    NEW_SECTION_H (nn).sh_offset += new_data2_size+data_bss_offset;
385abae
 #endif
385abae
 	  /* Any section that was originally placed after the section
385abae
 	     header table should now be off by the size of one section