diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/unexsunos4.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/unexsunos4.c b/src/unexsunos4.c index 25969256e07..379530f1e75 100644 --- a/src/unexsunos4.c +++ b/src/unexsunos4.c | |||
| @@ -56,10 +56,22 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 56 | #include <config.h> | 56 | #include <config.h> |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | #ifdef SUNOS4 | 59 | #if defined (SUNOS4) || defined (__FreeBSD__) |
| 60 | #define UNDO_RELOCATION | ||
| 61 | #endif | ||
| 62 | |||
| 63 | #ifdef UNDO_RELOCATION | ||
| 60 | #include <link.h> | 64 | #include <link.h> |
| 61 | #endif | 65 | #endif |
| 62 | 66 | ||
| 67 | #ifdef __FreeBSD__ | ||
| 68 | #define link_dynamic _dynamic | ||
| 69 | #define ld_un d_un | ||
| 70 | #define ld_2 d_sdt | ||
| 71 | #define ld_rel sdt_rel | ||
| 72 | #define ld_hash sdt_hash | ||
| 73 | #endif /* __FreeBSD__ */ | ||
| 74 | |||
| 63 | #ifdef HAVE_UNISTD_H | 75 | #ifdef HAVE_UNISTD_H |
| 64 | #include <unistd.h> | 76 | #include <unistd.h> |
| 65 | #endif | 77 | #endif |
| @@ -208,7 +220,7 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 208 | 220 | ||
| 209 | /* Some other BSD systems use this file. | 221 | /* Some other BSD systems use this file. |
| 210 | We don't know whether this change is right for them. */ | 222 | We don't know whether this change is right for them. */ |
| 211 | #ifdef SUNOS4 | 223 | #ifdef UNDO_RELOCATION |
| 212 | /* Undo the relocations done at startup by ld.so. | 224 | /* Undo the relocations done at startup by ld.so. |
| 213 | It will do these relocations again when we start the dumped Emacs. | 225 | It will do these relocations again when we start the dumped Emacs. |
| 214 | Doing them twice gives incorrect results. */ | 226 | Doing them twice gives incorrect results. */ |
| @@ -219,6 +231,7 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 219 | unsigned long rel, erel; | 231 | unsigned long rel, erel; |
| 220 | unsigned rel_size; | 232 | unsigned rel_size; |
| 221 | 233 | ||
| 234 | #ifdef SUNOS4 | ||
| 222 | if (_DYNAMIC.ld_version < 2) | 235 | if (_DYNAMIC.ld_version < 2) |
| 223 | { | 236 | { |
| 224 | rel = _DYNAMIC.ld_un.ld_1->ld_rel; | 237 | rel = _DYNAMIC.ld_un.ld_1->ld_rel; |
| @@ -243,6 +256,12 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 243 | default: | 256 | default: |
| 244 | fatal ("unknown machine type in unexec!\n"); | 257 | fatal ("unknown machine type in unexec!\n"); |
| 245 | } | 258 | } |
| 259 | #endif /* SUNOS4 */ | ||
| 260 | #ifdef __FreeBSD__ | ||
| 261 | rel = _DYNAMIC.ld_un.ld_2->ld_rel; | ||
| 262 | erel = _DYNAMIC.ld_un.ld_2->ld_hash; | ||
| 263 | rel_size = 8; /* sizeof(struct relocation_info) */ | ||
| 264 | #endif | ||
| 246 | 265 | ||
| 247 | for (; rel < erel; rel += rel_size) | 266 | for (; rel < erel; rel += rel_size) |
| 248 | { | 267 | { |
| @@ -259,7 +278,7 @@ unexec (new_name, a_name, bndry, bss_start, entry) | |||
| 259 | write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long)); | 278 | write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long)); |
| 260 | } | 279 | } |
| 261 | } | 280 | } |
| 262 | #endif /* SUNOS4 */ | 281 | #endif /* UNDO_RELOCATION */ |
| 263 | 282 | ||
| 264 | fchmod (new, 0755); | 283 | fchmod (new, 0755); |
| 265 | } | 284 | } |