Commit 1a63b3de authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

[SUNOS4]: Include link.h.

(unexec) [SUNOS4]: Cancel relocations that did.
parent 7e76ae23
/* Unexec for Sunos 4 using shared libraries.
Copyright (C) 1990, 1994 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Contributed by Viktor Dukhovni. */
* Unexec for Berkeley a.out format + SUNOS shared libraries
......@@ -37,6 +56,10 @@
#include <config.h>
#ifdef SUNOS4
#include <link.h>
#include <unistd.h>
......@@ -183,6 +206,56 @@ unexec (new_name, a_name, bndry, bss_start, entry)
lseek (new, N_TRELOFF (nhdr), L_SET);
write (new, old + N_TRELOFF (ohdr), stat.st_size - N_TRELOFF (ohdr));
/* Some other BSD systems use this file.
We don't know whether this change is right for them. */
#ifdef SUNOS4
/* Undo the relocations done at startup by
It will do these relocations again when we start the dumped Emacs.
Doing them twice gives incorrect results. */
extern struct link_dynamic _DYNAMIC;
unsigned long taddr = N_TXTADDR (ohdr);
unsigned long rel, erel;
unsigned rel_size;
if (_DYNAMIC.ld_version < 2)
rel = _DYNAMIC.ld_un.ld_1->ld_rel;
erel = _DYNAMIC.ld_un.ld_1->ld_hash;
rel = _DYNAMIC.ld_un.ld_2->ld_rel;
erel = _DYNAMIC.ld_un.ld_2->ld_hash;
switch (ohdr.a_machtype)
case M_68010:
case M_68020:
rel_size = 8; /* sizeof(struct reloc_info_m68k) */
case M_SPARC:
rel_size = 12; /* sizeof(struct reloc_info_sparc) */
case M_OLDSUN2:
fatal ("unknown machine type in unexec!\n");
for (; rel < erel; rel += rel_size)
unsigned long rpos = *(unsigned long *)(taddr + rel) - taddr;
if (rpos < (unsigned long)&data_start - taddr)
lseek (new, N_TXTOFF (nhdr) + rpos, L_SET);
write (new, old + N_TXTOFF (ohdr) + rpos, sizeof (unsigned long));
#endif /* SUNOS4 */
fchmod (new, 0755);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment