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-31) unstable; urgency=medium
 .
   * Version_2_6_13pre39
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/o/unexelf.c
+++ gcl-2.6.12/o/unexelf.c
@@ -428,6 +428,8 @@ extern void fatal (char *, ...);
 #include <syms.h> /* for HDRR declaration */
 #endif /* __sgi */
 
+#include "page.h"
+
 #ifndef MAP_ANON
 #ifdef MAP_ANONYMOUS
 #define MAP_ANON MAP_ANONYMOUS
@@ -655,7 +657,7 @@ unexec (char *new_name, char *old_name,
   char *old_section_names;
 
   ElfW(Addr) old_bss_addr, new_bss_addr,new_data2_addr;
-  ElfW(Off)  old_bss_size, new_data2_size,old_bss_offset,new_data2_offset,old_file_size,new_file_size;
+  ElfW(Off)  old_bss_size, new_data2_size,old_bss_offset,new_data2_offset,old_file_size,new_file_size,data_bss_offset;
 
   int n, nn;
   int old_bss_index, old_sbss_index;
@@ -772,7 +774,9 @@ unexec (char *new_name, char *old_name,
   if (new_file < 0)
     fatal ("Can't creat (%s): errno %d\n", new_name, errno);
 
-  new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size + (new_data2_offset-old_bss_offset);
+  data_bss_offset=CEI(new_data2_offset-old_bss_offset,sizeof(long));/*????, e.g. sparc64*/
+
+  new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size + data_bss_offset;
 
   if (ftruncate (new_file, new_file_size))
     fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
@@ -784,7 +788,7 @@ unexec (char *new_name, char *old_name,
   new_file_h = (ElfW(Ehdr) *) new_base;
   new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff);
   new_section_h = (ElfW(Shdr) *)
-    ((byte *) new_base + old_file_h->e_shoff + new_data2_size + (new_data2_offset-old_bss_offset));
+    ((byte *) new_base + old_file_h->e_shoff + new_data2_size + data_bss_offset);
 
 
   /* Make our new file, program and section headers as copies of the
@@ -802,7 +806,7 @@ unexec (char *new_name, char *old_name,
    * further away now.
    */
 
-  new_file_h->e_shoff += new_data2_size + (new_data2_offset-old_bss_offset);
+  new_file_h->e_shoff += new_data2_size + data_bss_offset;
   new_file_h->e_shnum += 1;
 
 #ifdef DEBUG
@@ -958,7 +962,7 @@ unexec (char *new_name, char *old_name,
 	  if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset ||
 	      /* solaris has symtab straddling bss offset */
 	      NEW_SECTION_H (nn).sh_offset+NEW_SECTION_H (nn).sh_size > old_bss_offset)
-	    NEW_SECTION_H (nn).sh_offset += new_data2_size+(new_data2_offset-old_bss_offset);
+	    NEW_SECTION_H (nn).sh_offset += new_data2_size+data_bss_offset;
 #endif
 	  /* Any section that was originally placed after the section
 	     header table should now be off by the size of one section