changeset 25940:3d7b096fb086

(unexec): Don't get confused by a short section just before the bss section.
author Phillip Rulon <pjr@gnu.org>
date Fri, 08 Oct 1999 23:08:28 +0000
parents a4a38fbd1bae
children aff7b4b37817
files src/unexelf.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/unexelf.c	Fri Oct 08 23:06:15 1999 +0000
+++ b/src/unexelf.c	Fri Oct 08 23:08:28 1999 +0000
@@ -926,9 +926,15 @@
 	      >= OLD_SECTION_H (old_bss_index-1).sh_offset)
 	    NEW_SECTION_H (nn).sh_offset += new_data2_size;
 #else
-	  if (round_up (NEW_SECTION_H (nn).sh_offset,
+	  /* The idea of this is that the bss section's sh_offset
+	     may need rounding up to compare with new_data2_offset.
+	     So we cannot simply compare the sh_offset.
+	     However, another small section could exist just before
+	     the bss section, and we need to know that is before.  */
+	  if (round_up (NEW_SECTION_H (nn).sh_offset
+			+ NEW_SECTION_H (nn).sh_size,
 			OLD_SECTION_H (old_bss_index).sh_addralign)
-	      >= new_data2_offset)
+	      > new_data2_offset)
 	    NEW_SECTION_H (nn).sh_offset += new_data2_size;
 #endif
 	  /* Any section that was originally placed after the section