diff options
| author | Richard M. Stallman | 1994-09-17 23:52:45 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-17 23:52:45 +0000 |
| commit | edd2556799c17c260c565f1bb43bae856a9c5b40 (patch) | |
| tree | 1dc3c579610f404e72e3676e7b19e4ed1d964066 /src | |
| parent | d0cb5e047d1ae957f4698cd42d9d10011130c060 (diff) | |
| download | emacs-edd2556799c17c260c565f1bb43bae856a9c5b40.tar.gz emacs-edd2556799c17c260c565f1bb43bae856a9c5b40.zip | |
(unexec): Fix logic for rounding section boundaries.
Diffstat (limited to 'src')
| -rw-r--r-- | src/unexsunos4.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/unexsunos4.c b/src/unexsunos4.c index d8cac642168..25969256e07 100644 --- a/src/unexsunos4.c +++ b/src/unexsunos4.c | |||
| @@ -214,7 +214,8 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 214 | Doing them twice gives incorrect results. */ | 214 | Doing them twice gives incorrect results. */ |
| 215 | { | 215 | { |
| 216 | extern struct link_dynamic _DYNAMIC; | 216 | extern struct link_dynamic _DYNAMIC; |
| 217 | unsigned long taddr = N_TXTADDR (ohdr); | 217 | unsigned long taddr = N_TXTADDR (ohdr) - N_TXTOFF (ohdr); |
| 218 | unsigned long daddr = N_DATADDR (ohdr) - N_DATOFF (ohdr); | ||
| 218 | unsigned long rel, erel; | 219 | unsigned long rel, erel; |
| 219 | unsigned rel_size; | 220 | unsigned rel_size; |
| 220 | 221 | ||
| @@ -245,10 +246,14 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 245 | 246 | ||
| 246 | for (; rel < erel; rel += rel_size) | 247 | for (; rel < erel; rel += rel_size) |
| 247 | { | 248 | { |
| 248 | unsigned long rpos = *(unsigned long *)(taddr + rel) - taddr; | 249 | /* This is the unadjusted address from the reloc. */ |
| 249 | 250 | unsigned long pos = *(unsigned long *)(taddr + rel); | |
| 250 | if (rpos < (unsigned long)&data_start - taddr) | 251 | /* This is the amount by which to adjust it. It |
| 251 | continue; | 252 | depends on which segment the address belongs to. */ |
| 253 | unsigned long offset = (pos < (unsigned long)&data_start | ||
| 254 | ? taddr : daddr); | ||
| 255 | /* This is the adjusted address from the reloc. */ | ||
| 256 | unsigned long rpos = pos - offset; | ||
| 252 | 257 | ||
| 253 | lseek (new, N_TXTOFF (nhdr) + rpos, L_SET); | 258 | lseek (new, N_TXTOFF (nhdr) + rpos, L_SET); |
| 254 | write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long)); | 259 | write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long)); |