Set up real-leim subdirectory,
with the real contents of leim; then move it to
a separate top-level directory.
Initialize a `leim' subdirectory with leim-Makefile.in.
Don't mention site-lisp, site-init, site-start
or default, when listing files hat are not compiled and should be.
line source
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Unexec for MIPS (including IRIS4D).
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 Note that the GNU project considers support for MIPS operation
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 a peripheral activity which should not be allowed to divert effort
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 from development of the GNU system. Changes in this code will be
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 installed when users send them in, but aside from that
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 we don't plan to think about it, or about whether other Emacs
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 maintenance might break it.
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 Copyright (C) 1988, 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
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 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, Inc., 59 Temple Place - Suite 330,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 Boston, MA 02111-1307, USA. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <config.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <sys/types.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <sys/file.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <sys/stat.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <stdio.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <varargs.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifdef MACH
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <a.out.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* I don't know why this isn't defined. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifndef STYP_INIT
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define STYP_INIT 0x80000000
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* I don't know why this isn't defined. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifndef _RDATA
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define _RDATA ".rdata"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define STYP_RDATA 0x00000100
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Small ("near") data section. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifndef _SDATA
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define _SDATA ".sdata"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define STYP_SDATA 0x00000200
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Small ("near") bss section. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifndef _SBSS
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define _SBSS ".sbss"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define STYP_SBSS 0x00000400
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* We don't seem to have a sym.h or syms.h anywhere, so we'll do it the
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hard way. This stinks. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 typedef struct {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 short magic;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 short vstamp;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 long ilineMax;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct { long foo, offset; } offsets[11];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } HDRR, *pHDRR;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #else /* not MACH */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <filehdr.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <aouthdr.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <scnhdr.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <sym.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif /* not MACH */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #if defined (IRIS_4D) || defined (sony)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include "getpagesize.h"
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #include <fcntl.h>
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static void fatal_unexec ();
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static void mark_x ();
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define READ(_fd, _buffer, _size, _error_message, _error_arg) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 errno = EEOF; \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (read (_fd, _buffer, _size) != _size) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec (_error_message, _error_arg);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (write (_fd, _buffer, _size) != _size) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec (_error_message, _error_arg);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define SEEK(_fd, _position, _error_message, _error_arg) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 errno = EEOF; \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (lseek (_fd, _position, L_SET) != _position) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec (_error_message, _error_arg);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 extern int errno;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 extern char *strerror ();
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define EEOF -1
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *text_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *init_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *finit_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *rdata_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *data_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *lit8_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *lit4_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *sdata_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *sbss_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static struct scnhdr *bss_section;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct headers {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct filehdr fhdr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct aouthdr aout;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct scnhdr section[10];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 };
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Define name of label for entry point for the dumped executable. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifndef DEFAULT_ENTRY_ADDRESS
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define DEFAULT_ENTRY_ADDRESS __start
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 unexec (new_name, a_name, data_start, bss_start, entry_address)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 char *new_name, *a_name;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 unsigned data_start, bss_start, entry_address;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int new, old;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int pagesize, brk;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int newsyms, symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int nread;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct headers hdr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int i;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int vaddr, scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define BUFSIZE 8192
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 char buffer[BUFSIZE];
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 old = open (a_name, O_RDONLY, 0);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (old < 0) fatal_unexec ("opening %s", a_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 new = creat (new_name, 0666);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (new < 0) fatal_unexec ("creating %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr = *((struct headers *)TEXT_START);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifdef MIPS2
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (hdr.fhdr.f_magic != MIPSELMAGIC
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 && hdr.fhdr.f_magic != MIPSEBMAGIC
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 && hdr.fhdr.f_magic != (MIPSELMAGIC | 1)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 && hdr.fhdr.f_magic != (MIPSEBMAGIC | 1))
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "unexec: input file magic number is %x, not %x, %x, %x or %x.\n",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.fhdr.f_magic,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 MIPSELMAGIC, MIPSEBMAGIC,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 MIPSELMAGIC | 1, MIPSEBMAGIC | 1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 exit(1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #else /* not MIPS2 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (hdr.fhdr.f_magic != MIPSELMAGIC
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 && hdr.fhdr.f_magic != MIPSEBMAGIC)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: input file magic number is %x, not %x or %x.\n",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.fhdr.f_magic, MIPSELMAGIC, MIPSEBMAGIC);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 exit (1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif /* not MIPS2 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (hdr.fhdr.f_opthdr != sizeof (hdr.aout))
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: input a.out header is %d bytes, not %d.\n",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.fhdr.f_opthdr, sizeof (hdr.aout));
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 exit (1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (hdr.aout.magic != ZMAGIC)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: input file a.out magic number is %o, not %o.\n",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.magic, ZMAGIC);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 exit (1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define CHECK_SCNHDR(ptr, name, flags) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 ptr = NULL; \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 for (i = 0; i < hdr.fhdr.f_nscns && !ptr; i++) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (strcmp (hdr.section[i].s_name, name) == 0) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 { \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (hdr.section[i].s_flags != flags) \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.section[i].s_flags, flags, name); \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 ptr = hdr.section + i; \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } \
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (text_section, _TEXT, STYP_TEXT);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (init_section, _INIT, STYP_INIT);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (data_section, _DATA, STYP_DATA);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifdef _LIT8
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (lit8_section, _LIT8, STYP_LIT8);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (lit4_section, _LIT4, STYP_LIT4);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif /* _LIT8 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 CHECK_SCNHDR (bss_section, _BSS, STYP_BSS);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #if 0 /* Apparently this error check goes off on irix 3.3,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 but it doesn't indicate a real problem. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (i != hdr.fhdr.f_nscns)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: %d sections found instead of %d.\n",
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 i, hdr.fhdr.f_nscns);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 text_section->s_scnptr = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 pagesize = getpagesize ();
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Casting to int avoids compiler error on NEWS-OS 5.0.2. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 brk = (((int) (sbrk (0))) + pagesize - 1) & (-pagesize);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.dsize = brk - DATA_START;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.bsize = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (entry_address == 0)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 extern DEFAULT_ENTRY_ADDRESS ();
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.entry = (unsigned)DEFAULT_ENTRY_ADDRESS;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.entry = entry_address;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 rdata_section->s_size = data_start - DATA_START;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /* Adjust start and virtual addresses of rdata_section, too. */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 rdata_section->s_vaddr = DATA_START;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 rdata_section->s_paddr = DATA_START;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 rdata_section->s_scnptr = text_section->s_scnptr + hdr.aout.tsize;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 data_section->s_vaddr = data_start;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 data_section->s_paddr = data_start;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 data_section->s_size = brk - data_start;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 vaddr = data_section->s_vaddr + data_section->s_size;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 scnptr = data_section->s_scnptr + data_section->s_size;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (lit8_section != NULL)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit8_section->s_vaddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit8_section->s_paddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit8_section->s_size = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit8_section->s_scnptr = scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (lit4_section != NULL)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit4_section->s_vaddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit4_section->s_paddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit4_section->s_size = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 lit4_section->s_scnptr = scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (sdata_section != NULL)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sdata_section->s_vaddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sdata_section->s_paddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sdata_section->s_size = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sdata_section->s_scnptr = scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (sbss_section != NULL)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sbss_section->s_vaddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sbss_section->s_paddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sbss_section->s_size = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sbss_section->s_scnptr = scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (bss_section != NULL)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 bss_section->s_vaddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 bss_section->s_paddr = vaddr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 bss_section->s_size = 0;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 bss_section->s_scnptr = scnptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 WRITE (new, (char *)TEXT_START, hdr.aout.tsize,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "writing text section to %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 WRITE (new, (char *)DATA_START, hdr.aout.dsize,
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "writing data section to %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 SEEK (old, hdr.fhdr.f_symptr, "seeking to start of symbols in %s", a_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 errno = EEOF;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 nread = read (old, buffer, BUFSIZE);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (nread < sizeof (HDRR)) fatal_unexec ("reading symbols from %s", a_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 newsyms = hdr.aout.tsize + hdr.aout.dsize;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symrel = newsyms - hdr.fhdr.f_symptr;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 hdr.fhdr.f_symptr = newsyms;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #define symhdr ((pHDRR)buffer)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #ifdef MACH
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 for (i = 0; i < 11; i++)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->offsets[i].offset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbLineOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbDnOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbPdOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbSymOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbOptOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbAuxOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbSsOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbSsExtOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbFdOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbRfdOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 symhdr->cbExtOffset += symrel;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #endif
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #undef symhdr
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 do
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (write (new, buffer, nread) != nread)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec ("writing symbols to %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 nread = read (old, buffer, BUFSIZE);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (nread < 0) fatal_unexec ("reading symbols from %s", a_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 #undef BUFSIZE
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 } while (nread != 0);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 SEEK (new, 0, "seeking to start of header in %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 WRITE (new, &hdr, sizeof (hdr),
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 "writing header of %s", new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 close (old);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 close (new);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 mark_x (new_name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 /*
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 * mark_x
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 *
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 * After successfully building the new a.out, mark it executable
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 */
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static void
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 mark_x (name)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 char *name;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 struct stat sbuf;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 int um = umask (777);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 umask (um);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (stat (name, &sbuf) < 0)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec ("getting protection on %s", name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 sbuf.st_mode |= 0111 & ~um;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (chmod (name, sbuf.st_mode) < 0)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec ("setting protection on %s", name);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 static void
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fatal_unexec (s, va_alist)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 va_dcl
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 {
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 va_list ap;
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 if (errno == EEOF)
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fputs ("unexec: unexpected end of file, ", stderr);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 else
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fprintf (stderr, "unexec: %s, ", strerror (errno));
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 va_start (ap);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 _doprnt (s, ap, stderr);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 fputs (".\n", stderr);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 exit (1);
+ 鐃緒申��申鐃初姐�渇����鐃醇�鐃緒申��申鐃緒申 }