changeset 1094:861c2997afee

(unexec): Allow sections in any order. Adjust addresses of rdata section as well as data section.
author Richard M. Stallman <rms@gnu.org>
date Fri, 11 Sep 1992 23:29:02 +0000
parents 64d7858e7b48
children 6578f07e9eb8
files src/unexmips.c
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/unexmips.c	Fri Sep 11 23:28:03 1992 +0000
+++ b/src/unexmips.c	Fri Sep 11 23:29:02 1992 +0000
@@ -141,18 +141,16 @@
     }
 
 #define CHECK_SCNHDR(ptr, name, flags)					\
-  if (strcmp (hdr.section[i].s_name, name) == 0)			\
-    {									\
-      if (hdr.section[i].s_flags != flags)				\
-	fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \
-		 hdr.section[i].s_flags, flags, name);			\
-      ptr = hdr.section + i;						\
-      i += 1;								\
-    }									\
-  else									\
-    ptr = NULL;
+  ptr = NULL;								\
+  for (i = 0; i < hdr.fhdr.f_nscns && !ptr; i++)			\
+    if (strcmp (hdr.section[i].s_name, name) == 0)			\
+      {									\
+	if (hdr.section[i].s_flags != flags)				\
+	  fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \
+		   hdr.section[i].s_flags, flags, name);		\
+	ptr = hdr.section + i;						\
+      }									\
 
-  i = 0;
   CHECK_SCNHDR (text_section,  _TEXT,  STYP_TEXT);
   CHECK_SCNHDR (init_section,  _INIT,  STYP_INIT);
   CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA);
@@ -182,6 +180,12 @@
 
   hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
   rdata_section->s_size = data_start - DATA_START;
+
+  /* Adjust start and virtual addresses of rdata_section, too.  */
+  rdata_section->s_vaddr = DATA_START;
+  rdata_section->s_paddr = DATA_START;
+  rdata_section->s_scnptr = text_section->s_scnptr + hdr.aout.tsize;
+
   data_section->s_vaddr = data_start;
   data_section->s_paddr = data_start;
   data_section->s_size = brk - data_start;