<short summary of the patch>
authorCamm Maguire <camm@debian.org>
Thu, 11 Aug 2022 17:16:42 +0000 (18:16 +0100)
committerCamm Maguire <camm@debian.org>
Thu, 11 Aug 2022 17:16:42 +0000 (18:16 +0100)
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

Gbp-Pq: Name data_bss_offset-in-unexec-sparc64-fix

o/unexelf.c

index 40f60c54dfc168355144205591e56d748968cf37..78dc68eb208f812d912c17e11ca588051676d068 100755 (executable)
@@ -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, unsigned int data_start, unsigned int bs
   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, unsigned int data_start, unsigned int bs
   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, unsigned int data_start, unsigned int bs
   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, unsigned int data_start, unsigned int bs
    * 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, unsigned int data_start, unsigned int bs
          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