# HG changeset patch # User Richard M. Stallman # Date 779845965 0 # Node ID 3fe65c32616b51d3c0fb328dd6b1f62f2a3ee231 # Parent 65731429a2c1d87cf85ca931626b1bcc5eb1de62 (unexec): Fix logic for rounding section boundaries. diff -r 65731429a2c1 -r 3fe65c32616b src/unexsunos4.c --- 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));