aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-09-17 10:22:21 +0000
committerRichard M. Stallman1994-09-17 10:22:21 +0000
commit1a63b3de3637d53dbbacf83569c2c137971b4c45 (patch)
tree27861173a37ecad60b0c29d5f37490a96b179a21 /src
parent7e76ae2395e75949c865ac0c7cfde7e1b0b70532 (diff)
downloademacs-1a63b3de3637d53dbbacf83569c2c137971b4c45.tar.gz
emacs-1a63b3de3637d53dbbacf83569c2c137971b4c45.zip
[SUNOS4]: Include link.h.
(unexec) [SUNOS4]: Cancel relocations that ld.so did.
Diffstat (limited to 'src')
-rw-r--r--src/unexsunos4.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/unexsunos4.c b/src/unexsunos4.c
index 53c3dc13bf9..d8cac642168 100644
--- a/src/unexsunos4.c
+++ b/src/unexsunos4.c
@@ -1,3 +1,22 @@
1/* Unexec for Sunos 4 using shared libraries.
2 Copyright (C) 1990, 1994 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
1/* Contributed by Viktor Dukhovni. */ 20/* Contributed by Viktor Dukhovni. */
2/* 21/*
3 * Unexec for Berkeley a.out format + SUNOS shared libraries 22 * Unexec for Berkeley a.out format + SUNOS shared libraries
@@ -37,6 +56,10 @@
37#include <config.h> 56#include <config.h>
38#endif 57#endif
39 58
59#ifdef SUNOS4
60#include <link.h>
61#endif
62
40#ifdef HAVE_UNISTD_H 63#ifdef HAVE_UNISTD_H
41#include <unistd.h> 64#include <unistd.h>
42#endif 65#endif
@@ -183,6 +206,56 @@ unexec (new_name, a_name, bndry, bss_start, entry)
183 lseek (new, N_TRELOFF (nhdr), L_SET); 206 lseek (new, N_TRELOFF (nhdr), L_SET);
184 write (new, old + N_TRELOFF (ohdr), stat.st_size - N_TRELOFF (ohdr)); 207 write (new, old + N_TRELOFF (ohdr), stat.st_size - N_TRELOFF (ohdr));
185 208
209 /* Some other BSD systems use this file.
210 We don't know whether this change is right for them. */
211#ifdef SUNOS4
212 /* Undo the relocations done at startup by ld.so.
213 It will do these relocations again when we start the dumped Emacs.
214 Doing them twice gives incorrect results. */
215 {
216 extern struct link_dynamic _DYNAMIC;
217 unsigned long taddr = N_TXTADDR (ohdr);
218 unsigned long rel, erel;
219 unsigned rel_size;
220
221 if (_DYNAMIC.ld_version < 2)
222 {
223 rel = _DYNAMIC.ld_un.ld_1->ld_rel;
224 erel = _DYNAMIC.ld_un.ld_1->ld_hash;
225 }
226 else
227 {
228 rel = _DYNAMIC.ld_un.ld_2->ld_rel;
229 erel = _DYNAMIC.ld_un.ld_2->ld_hash;
230 }
231
232 switch (ohdr.a_machtype)
233 {
234 case M_68010:
235 case M_68020:
236 rel_size = 8; /* sizeof(struct reloc_info_m68k) */
237 break;
238 case M_SPARC:
239 rel_size = 12; /* sizeof(struct reloc_info_sparc) */
240 break;
241 case M_OLDSUN2:
242 default:
243 fatal ("unknown machine type in unexec!\n");
244 }
245
246 for (; rel < erel; rel += rel_size)
247 {
248 unsigned long rpos = *(unsigned long *)(taddr + rel) - taddr;
249
250 if (rpos < (unsigned long)&data_start - taddr)
251 continue;
252
253 lseek (new, N_TXTOFF (nhdr) + rpos, L_SET);
254 write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long));
255 }
256 }
257#endif /* SUNOS4 */
258
186 fchmod (new, 0755); 259 fchmod (new, 0755);
187} 260}
188 261