Mercurial > emacs
changeset 8865:3fe65c32616b
(unexec): Fix logic for rounding section boundaries.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 17 Sep 1994 23:52:45 +0000 |
parents | 65731429a2c1 |
children | 48a0ea73a9d7 |
files | src/unexsunos4.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/unexsunos4.c Sat Sep 17 20:02:15 1994 +0000 +++ b/src/unexsunos4.c Sat Sep 17 23:52:45 1994 +0000 @@ -214,7 +214,8 @@ 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 @@ 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));