# HG changeset patch # User Richard M. Stallman # Date 795136361 0 # Node ID 842974f9ab7d2af27615b99fd6db856c2efcae4c # Parent d173d21f14e2d8768e1f52a78f34adfa8b28923f (unexec): Adjust the file offset of sections located after the section header table. diff -r d173d21f14e2 -r 842974f9ab7d src/unexelf.c --- a/src/unexelf.c Mon Mar 13 22:50:35 1995 +0000 +++ b/src/unexelf.c Mon Mar 13 23:12:41 1995 +0000 @@ -719,11 +719,19 @@ NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (nn).sh_addralign; NEW_SECTION_H (nn).sh_size = 0; } - /* Any section that was original placed AFTER the bss section should now - be off by NEW_DATA2_SIZE. */ - else if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset) - NEW_SECTION_H (nn).sh_offset += new_data2_size; - + else + { + /* Any section that was original placed AFTER the bss + section should now be off by NEW_DATA2_SIZE. */ + if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset) + NEW_SECTION_H (nn).sh_offset += new_data2_size; + /* Any section that was originally placed after the section + header table should now be off by the size of one section + header table entry. */ + if (NEW_SECTION_H (nn).sh_offset > new_file_h->e_shoff) + NEW_SECTION_H (nn).sh_offset += new_file_h->e_shentsize; + } + /* If any section hdr refers to the section after the new .data section, make it refer to next one because we have inserted a new section in between. */