summaryrefslogtreecommitdiff
path: root/src/unexsunos4.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-09-20 06:12:27 +0000
committerRichard M. Stallman <rms@gnu.org>1994-09-20 06:12:27 +0000
commit90e8b54b3ba83ed984b3fd50987c3dd076ccde14 (patch)
tree9034ccb6f3453d170d358442e314b883b87897eb /src/unexsunos4.c
parent1bc280c7e0c96d37e298605d2df497f6a01cbd07 (diff)
downloademacs-90e8b54b3ba83ed984b3fd50987c3dd076ccde14.tar.gz
(SUNOS4 or __FreeBSD__): Define UNDO_RELOCATION.
(unexec): Test UNDO_RELOCATION. Distinguish the relocation formats of __FreeBSD__ and SUNOS4.
Diffstat (limited to 'src/unexsunos4.c')
-rw-r--r--src/unexsunos4.c25
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. */
#include <config.h>
#endif
-#ifdef SUNOS4
+#if defined (SUNOS4) || defined (__FreeBSD__)
+#define UNDO_RELOCATION
+#endif
+
+#ifdef UNDO_RELOCATION
#include <link.h>
#endif
+#ifdef __FreeBSD__
+#define link_dynamic _dynamic
+#define ld_un d_un
+#define ld_2 d_sdt
+#define ld_rel sdt_rel
+#define ld_hash sdt_hash
+#endif /* __FreeBSD__ */
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -208,7 +220,7 @@ unexec (new_name, a_name, bndry, bss_start, entry)
/* Some other BSD systems use this file.
We don't know whether this change is right for them. */
-#ifdef SUNOS4
+#ifdef UNDO_RELOCATION
/* Undo the relocations done at startup by ld.so.
It will do these relocations again when we start the dumped Emacs.
Doing them twice gives incorrect results. */
@@ -219,6 +231,7 @@ unexec (new_name, a_name, bndry, bss_start, entry)
unsigned long rel, erel;
unsigned rel_size;
+#ifdef SUNOS4
if (_DYNAMIC.ld_version < 2)
{
rel = _DYNAMIC.ld_un.ld_1->ld_rel;
@@ -243,6 +256,12 @@ unexec (new_name, a_name, bndry, bss_start, entry)
default:
fatal ("unknown machine type in unexec!\n");
}
+#endif /* SUNOS4 */
+#ifdef __FreeBSD__
+ rel = _DYNAMIC.ld_un.ld_2->ld_rel;
+ erel = _DYNAMIC.ld_un.ld_2->ld_hash;
+ rel_size = 8; /* sizeof(struct relocation_info) */
+#endif
for (; rel < erel; rel += rel_size)
{
@@ -259,7 +278,7 @@ unexec (new_name, a_name, bndry, bss_start, entry)
write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long));
}
}
-#endif /* SUNOS4 */
+#endif /* UNDO_RELOCATION */
fchmod (new, 0755);
}