]> git.eshelyaron.com Git - emacs.git/commitdiff
(unexec): Fix logic for rounding section boundaries.
authorRichard M. Stallman <rms@gnu.org>
Sat, 17 Sep 1994 23:52:45 +0000 (23:52 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 17 Sep 1994 23:52:45 +0000 (23:52 +0000)
src/unexsunos4.c

index d8cac6421684d776056dbe280d43c92f5a27ce76..25969256e07392a68ec1f1aaba1db05696e4a4a5 100644 (file)
@@ -214,7 +214,8 @@ unexec (new_name, a_name, bndry, bss_start, entry)
      Doing them twice gives incorrect results.  */
   {
     extern struct link_dynamic _DYNAMIC;
-    unsigned long taddr = N_TXTADDR (ohdr);
+    unsigned long taddr = N_TXTADDR (ohdr) - N_TXTOFF (ohdr);
+    unsigned long daddr = N_DATADDR (ohdr) - N_DATOFF (ohdr);
     unsigned long rel, erel;
     unsigned rel_size;
 
@@ -245,10 +246,14 @@ unexec (new_name, a_name, bndry, bss_start, entry)
 
     for (; rel < erel; rel += rel_size)
       {
-       unsigned long rpos = *(unsigned long *)(taddr + rel) - taddr;
-
-       if (rpos < (unsigned long)&data_start - taddr)
-           continue;
+       /*  This is the unadjusted address from the reloc.  */
+       unsigned long pos = *(unsigned long *)(taddr + rel);
+       /*  This is the amount by which to adjust it.  It
+           depends on which segment the address belongs to.  */
+       unsigned long offset = (pos < (unsigned long)&data_start
+                               ? taddr : daddr);
+       /*  This is the adjusted address from the reloc.  */
+       unsigned long rpos = pos - offset;
 
         lseek (new, N_TXTOFF (nhdr) + rpos, L_SET);
         write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long));