From c40ac86f5be1d28d1c1aaed2f0946018850a25aa Mon Sep 17 00:00:00 2001 From: Camm Maguire Date: Sun, 13 Nov 2022 12:55:14 +0000 Subject: [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 Gbp-Pq: Name data_bss_offset-in-unexec-sparc64-fix --- o/unexelf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/o/unexelf.c b/o/unexelf.c index 40f60c5..78dc68e 100755 --- a/o/unexelf.c +++ b/o/unexelf.c @@ -428,6 +428,8 @@ extern void fatal (char *, ...); #include /* 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 -- 2.30.2