summaryrefslogtreecommitdiff
path: root/src/unexmips.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1992-09-11 23:29:02 +0000
committerRichard M. Stallman <rms@gnu.org>1992-09-11 23:29:02 +0000
commit4a27f175656537b339003b114470447ff6b6445a (patch)
tree096f0a03d26beef098df0e97eaa8d0ef0dabe283 /src/unexmips.c
parent1afb92aeafef53ae016dfcab5680e7f1aac6ad71 (diff)
downloademacs-4a27f175656537b339003b114470447ff6b6445a.tar.gz
(unexec): Allow sections in any order.
Adjust addresses of rdata section as well as data section.
Diffstat (limited to 'src/unexmips.c')
-rw-r--r--src/unexmips.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/unexmips.c b/src/unexmips.c
index 7f4d75de256..76de824d06a 100644
--- a/src/unexmips.c
+++ b/src/unexmips.c
@@ -141,18 +141,16 @@ unexec (new_name, a_name, data_start, bss_start, entry_address)
}
#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 @@ unexec (new_name, a_name, data_start, bss_start, entry_address)
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;