aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2020-08-29 15:53:16 +0200
committerUlrich Müller <ulm@gentoo.org>2020-08-29 15:53:16 +0200
commite00c17e371373584e79f22322f90ad84376172b5 (patch)
tree1b3bdb64fdbc90cf2ba914c74c5fae6430972666
parentFix compilation with glibc-2.32. (diff)
downloademacs-patches-e00c17e371373584e79f22322f90ad84376172b5.tar.gz
emacs-patches-e00c17e371373584e79f22322f90ad84376172b5.tar.bz2
emacs-patches-e00c17e371373584e79f22322f90ad84376172b5.zip
Include Noah Friedman's patches in the patchset.emacs-18.59-patches-13
The original download location appears to be dead: ftp://ftp.splode.com/pub/users/friedman/emacs/emacs-18.59-linux22x-elf-glibc21.diff.gz I could not find the file anywhere else (except on Gentoo mirrors). Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--emacs/18.59/00_all_linux22x-elf-glibc21.patch1372
1 files changed, 1372 insertions, 0 deletions
diff --git a/emacs/18.59/00_all_linux22x-elf-glibc21.patch b/emacs/18.59/00_all_linux22x-elf-glibc21.patch
new file mode 100644
index 0000000..96a2026
--- /dev/null
+++ b/emacs/18.59/00_all_linux22x-elf-glibc21.patch
@@ -0,0 +1,1372 @@
+Index: emacs-18.59/etc/ChangeLog
+diff -u emacs-18.59/etc/ChangeLog:1.1.1.1 emacs-18.59/etc/ChangeLog:1.1.1.1.2.1
+--- emacs-18.59/etc/ChangeLog:1.1.1.1 Wed Oct 21 15:17:21 1992
++++ emacs-18.59/etc/ChangeLog Sat May 30 20:34:34 1998
+@@ -1,3 +1,8 @@
++1998-05-30 Noah Friedman <friedman@splode.com>
++
++ * env.c (main): Declare sys_errlist if linux + glibc2.
++ Patch from Steve Baur <steve@xemacs.org>.
++
+ Wed Oct 21 18:21:39 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * Makefile: Emacstool and other Sun-only targets replaced.
+@@ -290,5 +295,3 @@
+ * server.c [not BSD and not HAVE_SYSVIPC]: fix error message.
+
+ * loadst.c (main) [XENIX]: use /usr/spool/mail, not /usr/mail.
+-
+-
+Index: emacs-18.59/etc/env.c
+diff -u emacs-18.59/etc/env.c:1.1.1.1 emacs-18.59/etc/env.c:1.1.1.1.2.1
+--- emacs-18.59/etc/env.c:1.1.1.1 Sat Jan 25 13:20:37 1992
++++ emacs-18.59/etc/env.c Sat May 30 20:34:36 1998
+@@ -198,7 +198,9 @@
+ else
+ {
+ extern int errno, sys_nerr;
++#if defined(LINUX) && !(defined (__GLIBC__) && (__GLIBC__ >= 2))
+ extern char *sys_errlist[];
++#endif
+
+ environ = nenv;
+ (void) execvp (*argv, argv);
+Index: emacs-18.59/src/ChangeLog
+diff -u emacs-18.59/src/ChangeLog:1.1.1.2 emacs-18.59/src/ChangeLog:1.1.1.2.2.4
+--- emacs-18.59/src/ChangeLog:1.1.1.2 Fri Oct 30 15:05:54 1992
++++ emacs-18.59/src/ChangeLog Fri Nov 5 00:19:56 1999
+@@ -1,3 +1,35 @@
++1999-11-05 Noah Friedman <friedman@splode.com>
++
++ * ymakefile [LIBS_TERMCAP]: Use -lncurses, not -lcurses.
++ Define TERMINFO.
++ [LIB_X11_LIB]: Add -L/usr/X11R6/lib
++
++ * s-linux.h [HAVE_DEV_PTMX]: Redefine FIRST_PTY_LETTER to 'z'.
++ Define PTY_NAME_SPRINTF.
++ Define PTY_TTY_NAME_SPRINTF.
++ [LIBS_TERMCAP]: Default to ncurses, not termcap.
++
++1998-05-30 Noah Friedman <friedman@splode.com>
++
++ Patches from Steve Baur <steve@xemacs.org>, received 1997-09-23.
++ * s-linux.h (MAXNAMLEN): Define if using glibc2.
++ (C_OPTIMIZE_SWITCH): More optimization switches.
++ * sysdep.c: Declare sys_errlist if using linux+glibc2.
++ * process.c: Here too.
++ * fileio.c: Here too.
++ * ymakefile (CFLAGS): Use both C_DEBUG_SWITCH and C_OPTIMIZE_SWITCH.
++
++Fri Jul 5 02:07:24 1996 Noah Friedman <friedman@prep.ai.mit.edu>
++
++ * s-linux.h: New file.
++ * m-intel386.h [linux]: Define ULIMIT_BREAK_VALUE, SEGMENT_MASK.
++ * unexelf.c: Replaced with version from Emacs 19.31.
++ * process.c [!BSD4_1]: Don't declare sys_siglist unless
++ SYS_SIGLIST_DECLARED is also undefined.
++ (create_process) [TIOCSCTTY]: Ignore failures from ioctl call.
++ * sysdep.c (sys_siglist): Don't define unless HAVE_SYS_SIGLIST
++ is undefined.
++
+ Fri Oct 30 18:10:34 1992 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+ * Version 18.59 released.
+@@ -832,7 +864,7 @@
+
+ Tue Jan 21 21:49:43 1992 (Eric Youngdale at youngdale@v6550c.nrl.navy.mil)
+
+- * sysdep.c (sys_access) [VMS]: Fix bug whereby the default rather
++ * sysdep.c (sys_access) [VMS]: Fix bug whereby the default rather
+ than the actual privileges were used to determine if we have
+ file access.
+
+@@ -844,7 +876,7 @@
+ Sun Jan 19 23:39:10 1992 (Eric Youngdale at youngdale@v6550c.nrl.navy.mil)
+
+ * compile.com: Delete useless object file generated when sensing
+- the presence of a C compiler. Prevent user from seeing error
++ the presence of a C compiler. Prevent user from seeing error
+ message when sensing C compiler.
+
+ Sun Jan 19 11:29:00 1992 (Eric Youngdale at youngdale@v6550c.nrl.navy.mil)
+@@ -980,7 +1012,7 @@
+ (LIB_STANDARD): Remove -lbsd and -lrts.
+ Suggested by tranle@intellicorp.com.
+
+- * sysdep.c (child_setup_tty) [AIX]: If process_send_signal will use
++ * sysdep.c (child_setup_tty) [AIX]: If process_send_signal will use
+ chars, make sure we have chars for VQUIT and VINTR.
+
+ * lisp.h (DEFVARPERBUFFER, DEFVAR_PER_BUFFER):
+@@ -1038,7 +1070,7 @@
+
+ Mon Oct 21 23:05:15 1991 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+- * buffer.c: Doc fix.
++ * buffer.c: Doc fix.
+
+ Sun Oct 20 18:41:06 1991 Richard Stallman (rms@mole.gnu.ai.mit.edu)
+
+@@ -1313,7 +1345,7 @@
+ Sun Jul 7 15:47:50 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu)
+
+ * process.c (Fprocess_send_eof): If using a pipe, close it.
+- (close_process_descs): Check IN and OUT for nonzeroness.
++ (close_process_descs): Check IN and OUT for nonzeroness.
+
+ Thu Jul 4 00:18:48 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu)
+
+@@ -1512,7 +1544,7 @@
+ and __DATA correctly bracket the impure memory. Increase size of
+ sdata and DATA_START, to make sure that impure memory starts at an
+ address > 8191, since otherwise garbage collection gets very
+- confused and Emacs bombs with peculiar errors.
++ confused and Emacs bombs with peculiar errors.
+
+ Remove some flotsam in mapin_data - someone was trying to save the
+ argv and argc parameters, but never bothered to pass them in the
+@@ -2208,7 +2240,7 @@
+
+ * lisp.h (struct handler): Add new element `poll_suppress_count',
+ which records the value of that variable at the time the handler
+- is bound.
++ is bound.
+ * eval.c (Fcondition_case): Initialize new element.
+ (internal_condition_case): Likewise.
+ (Fsignal): Instead of calling `barf_if_polling_suppressed', abort
+@@ -2435,7 +2467,7 @@
+
+ * x11fns.c (Fcoordinates_in_window_p): Don't fail in minibuffer.
+
+- * x11term.c (internal_socket_read): Backwards if in FocusOut.
++ * x11term.c (internal_socket_read): Backwards if in FocusOut.
+
+ * term.c (fatal): Declare argument str.
+
+@@ -2672,7 +2704,7 @@
+
+ * term.c (calculate_costs): Make DC_ICcost one element larger.
+
+- * process.c (allocate_pty, create_process):
++ * process.c (allocate_pty, create_process):
+ (Fopen_network_stream, wait_reading_process_input):
+ Use O_NONBLOCK if it is defined.
+ (wait_reading_process_input): Ignore nread == 0 if using O_NDELAY.
+@@ -2716,7 +2748,7 @@
+
+ Sun Jul 29 14:16:05 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+
+- * x11term.c (local_cursor_vpos, local_cursor_hpos):
++ * x11term.c (local_cursor_vpos, local_cursor_hpos):
+ New variables, used throughout this file instead of cursor_*.
+ (XTupdate_end): Move cursor to last specified position.
+ This makes cursor_in_echo_area work.
+@@ -2864,7 +2896,7 @@
+ Add missing else in handling cursor_in_echo_area.
+
+ * window.c (Fselect_window): Always get point from the new window.
+- * xdisp.c (redisplay_window): Eliminate lpoint. Alter opoint
++ * xdisp.c (redisplay_window): Eliminate lpoint. Alter opoint
+ if point should be changed permanently in the selected window.
+
+ * xdisp.c (decode_mode_spec): Don't truncate buffer or file name.
+@@ -2878,7 +2910,7 @@
+ Tue May 22 20:50:33 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+
+ * Renamings: Renamed functions include
+- move_cursor, bell, read_command_char, insert, output_chars,
++ move_cursor, bell, read_command_char, insert, output_chars,
+ self_insert_internal, set_buffer_internal.
+ Variables echo_area_contents, cursor_hpos, cursor_vpos, meta_key,
+ update_mode_lines, current_buffer.
+@@ -2966,7 +2998,7 @@
+ * process.c (create_process) [not USG]: Put subproc in pgrp 0.
+
+ * buffer.c (SetBfp): Don't bother with selected window or its point.
+- * window.c (Fselect_window): Always set pointm of old window.
++ * window.c (Fselect_window): Always set pointm of old window.
+
+ Thu May 10 18:20:10 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+
+@@ -2983,7 +3015,7 @@
+ * buffer.c (SetBfp, Frename_buffer): Local cleanups.
+
+ * buffer.c (Fset_buffer): Check for deleted buffer.
+- (SetBfp): Don't check.
++ (SetBfp): Don't check.
+ * print.c (PRINTPREPARE): Use Fset_buffer.
+
+ Tue May 8 23:00:00 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+@@ -3054,7 +3086,7 @@
+ * xdisp.c (try_window, try_window_id, display_text_line): Likewise.
+ (redisplay): Likewise.
+ * buffer.c (list_buffers_1): Likewise.
+- * marker.c (marker_position, Fset_marker, set_marker_restricted):
++ * marker.c (marker_position, Fset_marker, set_marker_restricted):
+ (Fmarker_position): Likewise.
+ * window.c (unshow_buffer, Fset_window_configuration): Likewise.
+ (Fset_window_buffer): Likewise.
+@@ -3091,7 +3123,7 @@
+
+ Mon Apr 30 20:00:00 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+
+- * sysdep.c (sys_suspend): Use save_signal_handlers and
++ * sysdep.c (sys_suspend): Use save_signal_handlers and
+ restore_signal_handlers to save and restore signal state.
+
+ * indent.c (Findent_to): Merge guts of indentation into here.
+@@ -3167,7 +3199,7 @@
+ * keyboard.c (echo_prompt, echo_char, echo_dash, echo): New functions.
+ (cancel_echoing): Likewise.
+ (immediate_echo, echoptr): New variables.
+- (command_loop_1, request_echo, get_char, read_key_sequence):
++ (command_loop_1, request_echo, get_char, read_key_sequence):
+ (set_waiting_for_input, interrupt_signal): Related changes.
+
+ * keyboard.c (this_command_key...): New variables.
+@@ -3416,7 +3448,7 @@
+ * m-ibmps2-aix.h (HAVE_CLOSEDIR): Define this.
+ * sysdep.c (closedir): Don't define if HAVE_CLOSEDIR.
+
+- * m-hp9000s300.h: Include sys/wait.h and define WAITTYPE,
++ * m-hp9000s300.h: Include sys/wait.h and define WAITTYPE,
+ unless NO_SHORTNAMES.
+
+ * process.c [BSD]: If O_NDELAY missing in file.h, include fcntl.h.
+@@ -4213,7 +4245,7 @@
+ * sysdep.c (setpriority) [USG]: No longer a no-op; use `nice'.
+
+ * keymap.c (Fwhere_is_internal): New 4th arg inhibits looking thru
+- indirect definitions--so you can search for one.
++ indirect definitions--so you can search for one.
+
+ * alloc.c, fns.c, search.c: Doc fix.
+
+@@ -4356,7 +4388,7 @@
+
+ Tue Sep 6 20:43:10 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu)
+
+- * search.c (search_buffer, string_match, looking_at):
++ * search.c (search_buffer, string_match, looking_at):
+ Report matcher stack overflow as error, not just failure to match.
+
+ * data.c (Fmake_local_variable): Add local variable to simplify
+Index: emacs-18.59/src/fileio.c
+diff -u emacs-18.59/src/fileio.c:1.1.1.2 emacs-18.59/src/fileio.c:1.1.1.2.2.1
+--- emacs-18.59/src/fileio.c:1.1.1.2 Tue Oct 6 15:02:20 1992
++++ emacs-18.59/src/fileio.c Sat May 30 20:34:39 1998
+@@ -45,7 +45,9 @@
+
+ #ifndef vax11c
+ extern int errno;
++#if defined(LINUX) && !(defined (__GLIBC__) && (__GLIBC__ >= 2))
+ extern char *sys_errlist[];
++#endif
+ extern int sys_nerr;
+ #endif
+
+Index: emacs-18.59/src/m-intel386.h
+diff -u emacs-18.59/src/m-intel386.h:1.1.1.1 emacs-18.59/src/m-intel386.h:1.1.1.1.2.1
+--- emacs-18.59/src/m-intel386.h:1.1.1.1 Tue Aug 25 14:59:27 1992
++++ emacs-18.59/src/m-intel386.h Sat May 30 19:35:47 1998
+@@ -182,3 +182,11 @@
+ #ifdef USG5_4
+ #define DATA_SEG_BITS 0x08000000
+ #endif
++
++#ifdef linux
++/* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */
++/* we cannot get the maximum address for brk */
++#define ULIMIT_BREAK_VALUE (32*1024*1024)
++
++#define SEGMENT_MASK ((SEGMENT_SIZE)-1)
++#endif
+Index: emacs-18.59/src/process.c
+diff -u emacs-18.59/src/process.c:1.1.1.2 emacs-18.59/src/process.c:1.1.1.2.2.2
+--- emacs-18.59/src/process.c:1.1.1.2 Sat Oct 24 21:42:04 1992
++++ emacs-18.59/src/process.c Sat May 30 20:34:40 1998
+@@ -190,10 +190,14 @@
+
+ extern errno;
+ extern sys_nerr;
++#if defined(LINUX) && !(defined (__GLIBC__) && (__GLIBC__ >= 2))
+ extern char *sys_errlist[];
++#endif
+
+ #ifndef BSD4_1
++#ifndef SYS_SIGLIST_DECLARED
+ extern char *sys_siglist[];
++#endif /* ! SYS_SYGLIST_DECLARED */
+ #else
+ char *sys_siglist[] =
+ {
+@@ -1227,8 +1231,8 @@
+ setsid ();
+ #ifdef TIOCSCTTY
+ /* Make the pty's terminal the controlling terminal. */
+- if (pty_flag && (ioctl (xforkin, TIOCSCTTY, 0) < 0))
+- abort ();
++ if (pty_flag)
++ ioctl (xforkin, TIOCSCTTY, 0); /* ignore errors for linux */
+ #endif
+ #else /* not HAVE_SETSID */
+ #ifdef USG
+Index: emacs-18.59/src/s-linux.h
+diff -u /dev/null emacs-18.59/src/s-linux.h:1.1.2.3
+--- /dev/null Sat Feb 19 20:04:54 2000
++++ emacs-18.59/src/s-linux.h Fri Nov 5 00:17:23 1999
+@@ -0,0 +1,260 @@
++/* Definitions file for GNU Emacs running on Linux
++ Copyright (C) 1985, 1986 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
++
++/* $Id: s-linux.h,v 1.1.2.3 1999/11/05 08:17:23 friedman Exp $ */
++/* This config.h written for Linux 2.0 ELF, gcc 2.7, libc 5.2, and X11R6 */
++
++/*
++ * Define symbols to identify the version of Unix this is.
++ * Define all the symbols that apply correctly.
++ */
++
++#define USG /* System III, System V, etc */
++#define USG5
++
++/* SYSTEM_TYPE should indicate the kind of system you are using.
++ It sets the Lisp variable system-type. */
++
++#define SYSTEM_TYPE "linux"
++
++/* nomultiplejobs should be defined if your system's shell
++ does not have "job control" (the ability to stop a program,
++ run some other program, then continue the first one). */
++
++/* #define NOMULTIPLEJOBS */
++
++/* This requires SIGIO to work properly; Linux 2.0 has it. */
++#define INTERRUPT_INPUT
++
++/* Letter to use in finding device name of first pty,
++ if system supports pty's. 'p' means it is /dev/ptyp0 */
++
++#define FIRST_PTY_LETTER 'p'
++
++/*
++ * Define HAVE_TERMIO if the system provides sysV-style ioctls
++ * for terminal control.
++ */
++
++#define HAVE_TERMIO
++
++/*
++ * Define HAVE_TIMEVAL if the system supports the BSD style clock values.
++ * Look in <sys/time.h> for a timeval structure.
++ */
++
++#define HAVE_TIMEVAL
++
++/*
++ * Define HAVE_SELECT if the system supports the `select' system call.
++ */
++
++#define HAVE_SELECT
++
++/*
++ * Define HAVE_PTYS if the system supports pty devices.
++ */
++
++#define HAVE_PTYS
++
++/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */
++
++#define HAVE_SOCKETS
++
++/*
++ * Define NONSYSTEM_DIR_LIBRARY to make Emacs emulate
++ * The 4.2 opendir, etc., library functions.
++ */
++
++/* #define NONSYSTEM_DIR_LIBRARY */
++
++/* Define this symbol if your system has the functions bcopy, etc. */
++
++#define BSTRING
++
++/* subprocesses should be defined if you want to
++ have code for asynchronous subprocesses
++ (as used in M-x compile and M-x shell).
++ This is supposed to work now on system V release 2. */
++
++#define subprocesses
++
++/* If your system uses COFF (Common Object File Format) then define the
++ preprocessor symbol "COFF". */
++
++/* #define COFF */
++
++/* define MAIL_USE_FLOCK if the mailer uses flock
++ to interlock access to /usr/spool/mail/$USER.
++ The alternative is that a lock file named
++ /usr/spool/mail/$USER.lock. */
++
++/* #define MAIL_USE_FLOCK */
++
++/* Define CLASH_DETECTION if you want lock files to be written
++ so that Emacs can tell instantly when you try to modify
++ a file that someone else has modified in his Emacs. */
++
++#define CLASH_DETECTION
++
++/* Define SHORTNAMES if the C compiler can distinguish only
++ short names. It means that the stuff in ../shortnames
++ must be run to convert the long names to short ones. */
++
++/* #define SHORTNAMES */
++
++/* extend max filesize to 32 Meg */
++#define VALBITS 26
++#define GCTYPEBITS 5
++
++
++/* Special hacks needed to make Emacs run on this system. */
++
++/* On USG systems the system calls are interruptable by signals
++ that the user program has elected to catch. Thus the system call
++ must be retried in these cases. To handle this without massive
++ changes in the source code, we remap the standard system call names
++ to names for our own functions in sysdep.c that do the system call
++ with retries. */
++
++#define open sys_open
++#define close sys_close
++#define read sys_read
++#define write sys_write
++
++#define INTERRUPTABLE_OPEN
++#define INTERRUPTABLE_CLOSE
++#define INTERRUPTABLE_IO
++
++/* let's see, what have we got here */
++
++#define HAVE_TCATTR /* fixes ^z problems */
++#define HAVE_SETSID /* fixes shell problems */
++#define HAVE_DUP2 /* is builtin */
++#define HAVE_GETTIMEOFDAY /* is builtin */
++#define HAVE_RENAME /* is builtin */
++#define HAVE_RANDOM /* is builtin */
++#define HAVE_CLOSEDIR /* we have a closedir */
++#define HAVE_GETPAGESIZE /* we now have getpagesize (0.96) */
++#define HAVE_VFORK /* we now have vfork (0.96) */
++#define HAVE_SYS_SIGLIST /* we have a (non-standard) sys_siglist */
++#define SYS_SIGLIST_DECLARED
++#define HAVE_GETWD /* cure conflict with getcwd? */
++
++#define NO_SIOCTL_H /* don't have sioctl.h */
++#define SYSV_SYSTEM_DIR /* use dirent.h */
++#define USG_SYS_TIME /* use sys/time.h, not time.h */
++
++#define POSIX /* affects only getpagesize.h */
++#define POSIX_SIGNALS /* uses sigaction from sys_signal */
++
++#ifdef HAVE_PTMX
++
++/* This change means that we don't loop through allocate_pty too many
++ times in the (rare) event of a failure. */
++
++#undef FIRST_PTY_LETTER
++#define FIRST_PTY_LETTER 'z'
++
++/* This sets the name of the master side of the PTY. */
++
++#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
++
++/* This is the same definition as in usg5-4.h, but with sigblock/sigunblock
++ rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't
++ work if POSIX_SIGNALS is defined. It may also be appropriate for SVR4.x
++ (x<2) but I'm not sure. fnf@cygnus.com */
++/* This sets the name of the slave side of the PTY. On SysVr4,
++ grantpt(3) forks a subprocess, so keep sigchld_handler() from
++ intercepting that death. If any child but grantpt's should die
++ within, it should be caught after sigrelse(2). */
++
++#undef PTY_TTY_NAME_SPRINTF
++#define PTY_TTY_NAME_SPRINTF \
++ { \
++ char *ptsname (), *ptyname; \
++ \
++ sigblock (sigmask (SIGCLD)); \
++ if (grantpt (fd) == -1) \
++ { close (fd); return -1; } \
++ sigunblock (sigmask (SIGCLD)); \
++ if (unlockpt (fd) == -1) \
++ { close (fd); return -1; } \
++ if (!(ptyname = ptsname (fd))) \
++ { close (fd); return -1; } \
++ strncpy (pty_name, ptyname, sizeof (pty_name)); \
++ pty_name[sizeof (pty_name) - 1] = 0; \
++ }
++
++#endif /* HAVE_PTMX */
++
++/* Unless this is defined, XFlush crashes emacs because of fd duping
++ performed in x11term.c (x_init_1). */
++#define SYSV_STREAMS
++
++/* note: system malloc does not work with shared libs
++ This was reported with earlier versions of linux (libc 4).
++ Still true?
++ */
++#if 0 /* choose for yourself */
++#define SYSTEM_MALLOC /* produces smaller binary */
++#endif
++
++/* misc. kludges for linux */
++#if !(defined (__GLIBC__) && (__GLIBC__ >= 2))
++#define MAXNAMLEN NAME_MAX /* missing SYSV-ism */
++#endif
++
++#define SIGSYS SIGUNUSED /* rename to harmless work-alike */
++#define VSWTCH VSWTC /* mis-spelling in termios.h? */
++
++/* we have non-standard standard I/O (iostream) ... */
++#ifdef emacs
++#include <stdio.h> /* Get the definition of _IO_STDIO_H. */
++#if defined(_IO_STDIO_H) || defined(_STDIO_USES_IOSTREAM)
++/* new C libio names */
++#define PENDING_OUTPUT_COUNT(FILE) \
++ ((FILE)->_IO_write_ptr - (FILE)->_IO_write_base)
++#else /* !_IO_STDIO_H */
++/* old C++ iostream names */
++#define PENDING_OUTPUT_COUNT(FILE) \
++ ((FILE)->_pptr - (FILE)->_pbase)
++#endif /* !_IO_STDIO_H */
++#endif /* emacs */
++
++/* This is for debugging; otherwise, gdb cannot access numerous structure
++ members like XXdisplay->fd, etc. */
++#define XLIB_ILLEGAL_ACCESS
++
++#ifdef __ELF__
++#define UNEXEC unexelf.o
++#define UNEXEC_USE_MAP_PRIVATE
++#define DATA_SEG_BITS 0x08000000
++#endif
++
++#define C_COMPILER gcc
++#define C_DEBUG_SWITCH -g
++#define C_OPTIMIZE_SWITCH -O3 -malign-loops=2 -malign-jumps=2 -malign-functions=2
++#define OLDXMENU_OPTIONS CFLAGS=-O2 EXTRA=insque.o
++#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o
++#define LIBS_DEBUG /* override in config.h to include -lg */
++#define LIBS_TERMCAP -lncurses
++#define LIBS_SYSTEM -lc /usr/lib/crtn.o
++
++/* s-linux.h ends here */
+Index: emacs-18.59/src/sysdep.c
+diff -u emacs-18.59/src/sysdep.c:1.1.1.2 emacs-18.59/src/sysdep.c:1.1.1.2.2.2
+--- emacs-18.59/src/sysdep.c:1.1.1.2 Sat Sep 12 00:25:30 1992
++++ emacs-18.59/src/sysdep.c Sat May 30 20:34:43 1998
+@@ -58,7 +58,8 @@
+ #include <errno.h>
+
+ extern int errno;
+-#ifndef VMS
++#if !defined(VMS) && (defined(LINUX) && \
++ !(defined (__GLIBC__) && (__GLIBC__ >= 2)))
+ extern char *sys_errlist[];
+ #endif
+
+@@ -2404,6 +2405,7 @@
+ * always negligible. Fred Fish, Unisoft Systems Inc.
+ */
+
++#ifndef HAVE_SYS_SIGLIST
+ char *sys_siglist[NSIG + 1] =
+ {
+ #ifdef AIX
+@@ -2464,6 +2466,7 @@
+ #endif /* not AIX */
+ 0
+ };
++#endif /* ! HAVE_SYS_SIGLIST */
+
+ /*
+ * Warning, this function may not duplicate 4.2 action properly
+Index: emacs-18.59/src/unexelf.c
+diff -u emacs-18.59/src/unexelf.c:1.1.1.1 emacs-18.59/src/unexelf.c:1.1.1.1.2.1
+--- emacs-18.59/src/unexelf.c:1.1.1.1 Sat Jan 25 15:57:26 1992
++++ emacs-18.59/src/unexelf.c Sat May 30 19:35:54 1998
+@@ -1,19 +1,23 @@
+-/* Copyright (C) 1985, 1986, 1987, 1988 Free Software Foundation, Inc.
++/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992
++ Free Software Foundation, Inc.
+
+- This program 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 1, or (at your option)
+- any later version.
+-
+- This program 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 this program; if not, write to the Free Software
+- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++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.
++
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding! */
+@@ -315,6 +319,99 @@
+
+ */
+
++/* Modified by wtien@urbana.mcd.mot.com of Motorola Inc.
++ *
++ * The above mechanism does not work if the unexeced ELF file is being
++ * re-layout by other applications (such as `strip'). All the applications
++ * that re-layout the internal of ELF will layout all sections in ascending
++ * order of their file offsets. After the re-layout, the data2 section will
++ * still be the LAST section in the section header vector, but its file offset
++ * is now being pushed far away down, and causes part of it not to be mapped
++ * in (ie. not covered by the load segment entry in PHDR vector), therefore
++ * causes the new binary to fail.
++ *
++ * The solution is to modify the unexec algorithm to insert the new data2
++ * section header right before the new bss section header, so their file
++ * offsets will be in the ascending order. Since some of the section's (all
++ * sections AFTER the bss section) indexes are now changed, we also need to
++ * modify some fields to make them point to the right sections. This is done
++ * by macro PATCH_INDEX. All the fields that need to be patched are:
++ *
++ * 1. ELF header e_shstrndx field.
++ * 2. section header sh_link and sh_info field.
++ * 3. symbol table entry st_shndx field.
++ *
++ * The above example now should look like:
++
++ **** SECTION HEADER TABLE ****
++[No] Type Flags Addr Offset Size Name
++ Link Info Adralgn Entsize
++
++[1] 1 2 0x80480d4 0xd4 0x13 .interp
++ 0 0 0x1 0
++
++[2] 5 2 0x80480e8 0xe8 0x388 .hash
++ 3 0 0x4 0x4
++
++[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
++ 4 1 0x4 0x10
++
++[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
++ 0 0 0x1 0
++
++[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
++ 3 7 0x4 0x8
++
++[6] 1 6 0x8049348 0x1348 0x3 .init
++ 0 0 0x4 0
++
++[7] 1 6 0x804934c 0x134c 0x680 .plt
++ 0 0 0x4 0x4
++
++[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
++ 0 0 0x4 0
++
++[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
++ 0 0 0x4 0
++
++[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
++ 0 0 0x4 0
++
++[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
++ 0 0 0x4 0
++
++[12] 1 3 0x8088330 0x3f330 0x20afc .data
++ 0 0 0x4 0
++
++[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
++ 0 0 0x4 0
++
++[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
++ 0 0 0x4 0x4
++
++[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
++ 4 0 0x4 0x8
++
++[16] 1 3 0x80a98f4 0x608f4 0x1cf0c .data
++ 0 0 0x4 0
++
++[17] 8 3 0x80c6800 0x7d800 0 .bss
++ 0 0 0x4 0
++
++[18] 2 0 0 0x7d800 0x9b90 .symtab
++ 19 371 0x4 0x10
++
++[19] 3 0 0 0x87390 0x8526 .strtab
++ 0 0 0x1 0
++
++[20] 3 0 0 0x8f8b6 0x93 .shstrtab
++ 0 0 0x1 0
++
++[21] 1 0 0 0x8f949 0x68b7 .comment
++ 0 0 0x1 0
++
++ */
++
+ #include <sys/types.h>
+ #include <stdio.h>
+ #include <sys/stat.h>
+@@ -327,14 +424,42 @@
+ #include <sys/mman.h>
+
+ #ifndef emacs
+-#define fatal(a, b, c) fprintf(stderr, a, b, c), exit(1)
++#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1)
+ #else
+-extern void fatal(char *, ...);
++#include "config.h"
++extern void fatal (char *, ...);
+ #endif
+
++#ifndef ELF_BSS_SECTION_NAME
++#define ELF_BSS_SECTION_NAME ".bss"
++#endif
++
+ /* Get the address of a particular section or program header entry,
+ * accounting for the size of the entries.
+ */
++/*
++ On PPC Reference Platform running Solaris 2.5.1
++ the plt section is also of type NOBI like the bss section.
++ (not really stored) and therefore sections after the bss
++ section start at the plt offset. The plt section is always
++ the one just before the bss section.
++ Thus, we modify the test from
++ if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset)
++ to
++ if (NEW_SECTION_H (nn).sh_offset >=
++ OLD_SECTION_H (old_bss_index-1).sh_offset)
++ This is just a hack. We should put the new data section
++ before the .plt section.
++ And we should not have this routine at all but use
++ the libelf library to read the old file and create the new
++ file.
++ The changed code is minimal and depends on prep set in m/prep.h
++ Erik Deumens
++ Quantum Theory Project
++ University of Florida
++ deumens@qtp.ufl.edu
++ Apr 23, 1996
++ */
+
+ #define OLD_SECTION_H(n) \
+ (*(Elf32_Shdr *) ((byte *) old_section_h + old_file_h->e_shentsize * (n)))
+@@ -345,6 +470,10 @@
+ #define NEW_PROGRAM_H(n) \
+ (*(Elf32_Phdr *) ((byte *) new_program_h + new_file_h->e_phentsize * (n)))
+
++#define PATCH_INDEX(n) \
++ do { \
++ if ((int) (n) >= old_bss_index) \
++ (n)++; } while (0)
+ typedef unsigned char byte;
+
+ /* Round X up to a multiple of Y. */
+@@ -373,7 +502,6 @@
+ char *new_name, *old_name;
+ unsigned data_start, bss_start, entry_address;
+ {
+- extern unsigned int bss_end;
+ int new_file, old_file, new_file_size;
+
+ /* Pointers to the base of the image of the two files. */
+@@ -394,7 +522,7 @@
+ Elf32_Off new_data2_offset;
+ Elf32_Addr new_data2_addr;
+
+- int n, old_bss_index, old_data_index, new_data2_index;
++ int n, nn, old_bss_index, old_data_index, new_data2_index;
+ struct stat stat_buf;
+
+ /* Open the old file & map it into the address space. */
+@@ -405,15 +533,15 @@
+ fatal ("Can't open %s for reading: errno %d\n", old_name, errno);
+
+ if (fstat (old_file, &stat_buf) == -1)
+- fatal ("Can't fstat(%s): errno %d\n", old_name, errno);
++ fatal ("Can't fstat (%s): errno %d\n", old_name, errno);
+
+ old_base = mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0);
+
+ if (old_base == (caddr_t) -1)
+- fatal ("Can't mmap(%s): errno %d\n", old_name, errno);
++ fatal ("Can't mmap (%s): errno %d\n", old_name, errno);
+
+ #ifdef DEBUG
+- fprintf (stderr, "mmap(%s, %x) -> %x\n", old_name, stat_buf.st_size,
++ fprintf (stderr, "mmap (%s, %x) -> %x\n", old_name, stat_buf.st_size,
+ old_base);
+ #endif
+
+@@ -423,36 +551,36 @@
+ old_program_h = (Elf32_Phdr *) ((byte *) old_base + old_file_h->e_phoff);
+ old_section_h = (Elf32_Shdr *) ((byte *) old_base + old_file_h->e_shoff);
+ old_section_names = (char *) old_base
+- + OLD_SECTION_H(old_file_h->e_shstrndx).sh_offset;
++ + OLD_SECTION_H (old_file_h->e_shstrndx).sh_offset;
+
+ /* Find the old .bss section. Figure out parameters of the new
+ * data2 and bss sections.
+ */
+
+- for (old_bss_index = 1; old_bss_index < old_file_h->e_shnum; old_bss_index++)
++ for (old_bss_index = 1; old_bss_index < (int) old_file_h->e_shnum;
++ old_bss_index++)
+ {
+ #ifdef DEBUG
+ fprintf (stderr, "Looking for .bss - found %s\n",
+- old_section_names + OLD_SECTION_H(old_bss_index).sh_name);
++ old_section_names + OLD_SECTION_H (old_bss_index).sh_name);
+ #endif
+- if (!strcmp (old_section_names + OLD_SECTION_H(old_bss_index).sh_name,
+- ".bss"))
++ if (!strcmp (old_section_names + OLD_SECTION_H (old_bss_index).sh_name,
++ ELF_BSS_SECTION_NAME))
+ break;
+ }
+ if (old_bss_index == old_file_h->e_shnum)
+ fatal ("Can't find .bss in %s.\n", old_name, 0);
+
+- old_bss_addr = OLD_SECTION_H(old_bss_index).sh_addr;
+- old_bss_size = OLD_SECTION_H(old_bss_index).sh_size;
++ old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr;
++ old_bss_size = OLD_SECTION_H (old_bss_index).sh_size;
+ #if defined(emacs) || !defined(DEBUG)
+- bss_end = (unsigned int) sbrk (0);
+- new_bss_addr = (Elf32_Addr) bss_end;
++ new_bss_addr = (Elf32_Addr) sbrk (0);
+ #else
+ new_bss_addr = old_bss_addr + old_bss_size + 0x1234;
+ #endif
+ new_data2_addr = old_bss_addr;
+ new_data2_size = new_bss_addr - old_bss_addr;
+- new_data2_offset = OLD_SECTION_H(old_bss_index).sh_offset;
++ new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset;
+
+ #ifdef DEBUG
+ fprintf (stderr, "old_bss_index %d\n", old_bss_index);
+@@ -467,25 +595,30 @@
+ if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size)
+ fatal (".bss shrank when undumping???\n", 0, 0);
+
+- /* Set the output file to the right size and mmap(2) it. Set
++ /* Set the output file to the right size and mmap it. Set
+ * pointers to various interesting objects. stat_buf still has
+ * old_file data.
+ */
+
+ new_file = open (new_name, O_RDWR | O_CREAT, 0666);
+ if (new_file < 0)
+- fatal ("Can't creat(%s): errno %d\n", new_name, errno);
++ fatal ("Can't creat (%s): errno %d\n", new_name, errno);
+
+ new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size;
+
+ if (ftruncate (new_file, new_file_size))
+- fatal ("Can't ftruncate(%s): errno %d\n", new_name, errno);
++ fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
+
++#ifdef UNEXEC_USE_MAP_PRIVATE
++ new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
++ new_file, 0);
++#else
+ new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ new_file, 0);
++#endif
+
+ if (new_base == (caddr_t) -1)
+- fatal ("Can't mmap(%s): errno %d\n", new_name, errno);
++ fatal ("Can't mmap (%s): errno %d\n", new_name, errno);
+
+ new_file_h = (Elf32_Ehdr *) new_base;
+ new_program_h = (Elf32_Phdr *) ((byte *) new_base + old_file_h->e_phoff);
+@@ -499,8 +632,9 @@
+ memcpy (new_file_h, old_file_h, old_file_h->e_ehsize);
+ memcpy (new_program_h, old_program_h,
+ old_file_h->e_phnum * old_file_h->e_phentsize);
+- memcpy (new_section_h, old_section_h,
+- old_file_h->e_shnum * old_file_h->e_shentsize);
++
++ /* Modify the e_shstrndx if necessary. */
++ PATCH_INDEX (new_file_h->e_shstrndx);
+
+ /* Fix up file header. We'll add one section. Section header is
+ * further away now.
+@@ -531,10 +665,10 @@
+ if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
+ alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
+
+- if (NEW_PROGRAM_H(n).p_vaddr + NEW_PROGRAM_H(n).p_filesz > old_bss_addr)
++ if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr)
+ fatal ("Program segment above .bss in %s\n", old_name, 0);
+
+- if (NEW_PROGRAM_H(n).p_type == PT_LOAD
++ if (NEW_PROGRAM_H (n).p_type == PT_LOAD
+ && (round_up ((NEW_PROGRAM_H (n)).p_vaddr
+ + (NEW_PROGRAM_H (n)).p_filesz,
+ alignment)
+@@ -544,18 +678,18 @@
+ if (n < 0)
+ fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0);
+
+- NEW_PROGRAM_H(n).p_filesz += new_data2_size;
+- NEW_PROGRAM_H(n).p_memsz = NEW_PROGRAM_H(n).p_filesz;
++ NEW_PROGRAM_H (n).p_filesz += new_data2_size;
++ NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;
+
+ #if 0 /* Maybe allow section after data2 - does this ever happen? */
+ for (n = new_file_h->e_phnum - 1; n >= 0; n--)
+ {
+- if (NEW_PROGRAM_H(n).p_vaddr
+- && NEW_PROGRAM_H(n).p_vaddr >= new_data2_addr)
+- NEW_PROGRAM_H(n).p_vaddr += new_data2_size - old_bss_size;
++ if (NEW_PROGRAM_H (n).p_vaddr
++ && NEW_PROGRAM_H (n).p_vaddr >= new_data2_addr)
++ NEW_PROGRAM_H (n).p_vaddr += new_data2_size - old_bss_size;
+
+- if (NEW_PROGRAM_H(n).p_offset >= new_data2_offset)
+- NEW_PROGRAM_H(n).p_offset += new_data2_size;
++ if (NEW_PROGRAM_H (n).p_offset >= new_data2_offset)
++ NEW_PROGRAM_H (n).p_offset += new_data2_size;
+ }
+ #endif
+
+@@ -565,75 +699,208 @@
+ * is set. data2 section header gets added by copying the existing
+ * .data header and modifying the offset, address and size.
+ */
+-
+- for (n = 1; n < new_file_h->e_shnum; n++)
+- {
+- if (NEW_SECTION_H(n).sh_offset >= new_data2_offset)
+- NEW_SECTION_H(n).sh_offset += new_data2_size;
+-
+- if (NEW_SECTION_H(n).sh_addr
+- && NEW_SECTION_H(n).sh_addr >= new_data2_addr)
+- NEW_SECTION_H(n).sh_addr += new_data2_size - old_bss_size;
+- }
+-
+- new_data2_index = old_file_h->e_shnum;
+-
+- for (old_data_index = 1; old_data_index < old_file_h->e_shnum;
++ for (old_data_index = 1; old_data_index < (int) old_file_h->e_shnum;
+ old_data_index++)
+- if (!strcmp (old_section_names + OLD_SECTION_H(old_data_index).sh_name,
++ if (!strcmp (old_section_names + OLD_SECTION_H (old_data_index).sh_name,
+ ".data"))
+ break;
+ if (old_data_index == old_file_h->e_shnum)
+ fatal ("Can't find .data in %s.\n", old_name, 0);
+
+- memcpy (&NEW_SECTION_H(new_data2_index), &OLD_SECTION_H(old_data_index),
++ /* Walk through all section headers, insert the new data2 section right
++ before the new bss section. */
++ for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++)
++ {
++ caddr_t src;
++ /* If it is bss section, insert the new data2 section before it. */
++ if (n == old_bss_index)
++ {
++ /* Steal the data section header for this data2 section. */
++ memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index),
+ new_file_h->e_shentsize);
+
+- NEW_SECTION_H(new_data2_index).sh_addr = new_data2_addr;
+- NEW_SECTION_H(new_data2_index).sh_offset = new_data2_offset;
+- NEW_SECTION_H(new_data2_index).sh_size = new_data2_size;
+-
+- NEW_SECTION_H(old_bss_index).sh_size = 0;
+- NEW_SECTION_H(old_bss_index).sh_addr = new_data2_addr + new_data2_size;
++ NEW_SECTION_H (nn).sh_addr = new_data2_addr;
++ NEW_SECTION_H (nn).sh_offset = new_data2_offset;
++ NEW_SECTION_H (nn).sh_size = new_data2_size;
++ /* Use the bss section's alignment. This will assure that the
++ new data2 section always be placed in the same spot as the old
++ bss section by any other application. */
++ NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (n).sh_addralign;
++
++ /* Now copy over what we have in the memory now. */
++ memcpy (NEW_SECTION_H (nn).sh_offset + new_base,
++ (caddr_t) OLD_SECTION_H (n).sh_addr,
++ new_data2_size);
++ nn++;
++ }
++
++ memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n),
++ old_file_h->e_shentsize);
++
++ /* The new bss section's size is zero, and its file offset and virtual
++ address should be off by NEW_DATA2_SIZE. */
++ if (n == old_bss_index)
++ {
++ /* NN should be `old_bss_index + 1' at this point. */
++ NEW_SECTION_H (nn).sh_offset += new_data2_size;
++ NEW_SECTION_H (nn).sh_addr += new_data2_size;
++ /* Let the new bss section address alignment be the same as the
++ section address alignment followed the old bss section, so
++ this section will be placed in exactly the same place. */
++ NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (nn).sh_addralign;
++ NEW_SECTION_H (nn).sh_size = 0;
++ }
++ else
++ {
++ /* Any section that was original placed AFTER the bss
++ section should now be off by NEW_DATA2_SIZE. */
++#ifdef SOLARIS_POWERPC
++ /* On PPC Reference Platform running Solaris 2.5.1
++ the plt section is also of type NOBI like the bss section.
++ (not really stored) and therefore sections after the bss
++ section start at the plt offset. The plt section is always
++ the one just before the bss section.
++ It would be better to put the new data section before
++ the .plt section, or use libelf instead.
++ Erik Deumens, deumens@qtp.ufl.edu. */
++ if (NEW_SECTION_H (nn).sh_offset
++ >= OLD_SECTION_H (old_bss_index-1).sh_offset)
++ NEW_SECTION_H (nn).sh_offset += new_data2_size;
++#else
++ if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset)
++ NEW_SECTION_H (nn).sh_offset += new_data2_size;
++#endif
++ /* Any section that was originally placed after the section
++ header table should now be off by the size of one section
++ header table entry. */
++ if (NEW_SECTION_H (nn).sh_offset > new_file_h->e_shoff)
++ NEW_SECTION_H (nn).sh_offset += new_file_h->e_shentsize;
++ }
++
++ /* If any section hdr refers to the section after the new .data
++ section, make it refer to next one because we have inserted
++ a new section in between. */
++
++ PATCH_INDEX (NEW_SECTION_H (nn).sh_link);
++ /* For symbol tables, info is a symbol table index,
++ so don't change it. */
++ if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
++ && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
++ PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
++
++ /* Now, start to copy the content of sections. */
++ if (NEW_SECTION_H (nn).sh_type == SHT_NULL
++ || NEW_SECTION_H (nn).sh_type == SHT_NOBITS)
++ continue;
+
+ /* Write out the sections. .data and .data1 (and data2, called
+- * ".data" in the strings table) get copied from the current process
+- * instead of the old file.
+- */
++ ".data" in the strings table) get copied from the current process
++ instead of the old file. */
++ if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data")
++ || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
++ ".data1"))
++ src = (caddr_t) OLD_SECTION_H (n).sh_addr;
++ else
++ src = old_base + OLD_SECTION_H (n).sh_offset;
+
++ memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src,
++ NEW_SECTION_H (nn).sh_size);
++
++ /* If it is the symbol table, its st_shndx field needs to be patched. */
++ if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB
++ || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM)
++ {
++ Elf32_Shdr *spt = &NEW_SECTION_H (nn);
++ unsigned int num = spt->sh_size / spt->sh_entsize;
++ Elf32_Sym * sym = (Elf32_Sym *) (NEW_SECTION_H (nn).sh_offset +
++ new_base);
++ for (; num--; sym++)
++ {
++ if ((sym->st_shndx == SHN_UNDEF)
++ || (sym->st_shndx == SHN_ABS)
++ || (sym->st_shndx == SHN_COMMON))
++ continue;
++
++ PATCH_INDEX (sym->st_shndx);
++ }
++ }
++ }
++
++ /* Update the symbol values of _edata and _end. */
+ for (n = new_file_h->e_shnum - 1; n; n--)
+ {
+- caddr_t src;
++ byte *symnames;
++ Elf32_Sym *symp, *symendp;
+
+- if (NEW_SECTION_H(n).sh_type == SHT_NULL
+- || NEW_SECTION_H(n).sh_type == SHT_NOBITS)
++ if (NEW_SECTION_H (n).sh_type != SHT_DYNSYM
++ && NEW_SECTION_H (n).sh_type != SHT_SYMTAB)
+ continue;
+
+- if (!strcmp (old_section_names + NEW_SECTION_H(n).sh_name, ".data")
+- || !strcmp ((old_section_names + NEW_SECTION_H(n).sh_name),
+- ".data1"))
+- src = (caddr_t) NEW_SECTION_H(n).sh_addr;
+- else
+- src = old_base + OLD_SECTION_H(n).sh_offset;
++ symnames = ((byte *) new_base
++ + NEW_SECTION_H (NEW_SECTION_H (n).sh_link).sh_offset);
++ symp = (Elf32_Sym *) (NEW_SECTION_H (n).sh_offset + new_base);
++ symendp = (Elf32_Sym *) ((byte *)symp + NEW_SECTION_H (n).sh_size);
++
++ for (; symp < symendp; symp ++)
++ if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0
++ || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0)
++ memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
++ }
+
+- memcpy (NEW_SECTION_H(n).sh_offset + new_base, src,
+- NEW_SECTION_H(n).sh_size);
++ /* This loop seeks out relocation sections for the data section, so
++ that it can undo relocations performed by the runtime linker. */
++ for (n = new_file_h->e_shnum - 1; n; n--)
++ {
++ Elf32_Shdr section = NEW_SECTION_H (n);
++ switch (section.sh_type) {
++ default:
++ break;
++ case SHT_REL:
++ case SHT_RELA:
++ /* This code handles two different size structs, but there should
++ be no harm in that provided that r_offset is always the first
++ member. */
++ nn = section.sh_info;
++ if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
++ || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
++ ".data1"))
++ {
++ Elf32_Addr offset = NEW_SECTION_H (nn).sh_addr -
++ NEW_SECTION_H (nn).sh_offset;
++ caddr_t reloc = old_base + section.sh_offset, end;
++ for (end = reloc + section.sh_size; reloc < end;
++ reloc += section.sh_entsize)
++ {
++ Elf32_Addr addr = ((Elf32_Rel *) reloc)->r_offset - offset;
++ memcpy (new_base + addr, old_base + addr, 4);
+ }
++ }
++ break;
++ }
++ }
++
++#ifdef UNEXEC_USE_MAP_PRIVATE
++ if (lseek (new_file, 0, SEEK_SET) == -1)
++ fatal ("Can't rewind (%s): errno %d\n", new_name, errno);
++
++ if (write (new_file, new_base, new_file_size) != new_file_size)
++ fatal ("Can't write (%s): errno %d\n", new_name, errno);
++#endif
+
+- /* Close the files and make the new file executable */
++ /* Close the files and make the new file executable. */
+
+ if (close (old_file))
+- fatal ("Can't close(%s): errno %d\n", old_name, errno);
++ fatal ("Can't close (%s): errno %d\n", old_name, errno);
+
+ if (close (new_file))
+- fatal ("Can't close(%s): errno %d\n", new_name, errno);
++ fatal ("Can't close (%s): errno %d\n", new_name, errno);
+
+ if (stat (new_name, &stat_buf) == -1)
+- fatal ("Can't stat(%s): errno %d\n", new_name, errno);
++ fatal ("Can't stat (%s): errno %d\n", new_name, errno);
+
+ n = umask (777);
+ umask (n);
+ stat_buf.st_mode |= 0111 & ~n;
+ if (chmod (new_name, stat_buf.st_mode) == -1)
+- fatal ("Can't chmod(%s): errno %d\n", new_name, errno);
++ fatal ("Can't chmod (%s): errno %d\n", new_name, errno);
+ }
+Index: emacs-18.59/src/ymakefile
+diff -u emacs-18.59/src/ymakefile:1.1.1.1 emacs-18.59/src/ymakefile:1.1.1.1.2.2
+--- emacs-18.59/src/ymakefile:1.1.1.1 Tue Oct 6 11:44:28 1992
++++ emacs-18.59/src/ymakefile Fri Nov 5 00:19:47 1999
+@@ -161,7 +161,7 @@
+ #define LINKER gcc -nostdlib
+ #else
+ #define LINKER ld
+-#endif
++#endif
+ #endif /* not ORDINARY_LINK */
+ #endif /* no LINKER */
+
+@@ -191,7 +191,7 @@
+ SHORT= shortnames
+ #endif /* SHORTNAMES */
+
+-CFLAGS= C_DEBUG_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM
++CFLAGS= C_DEBUG_SWITCH C_OPTIMIZE_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM
+ /* DO NOT use -R. There is a special hack described in lastfile.c
+ which is used instead. Some initialized data areas are modified
+ at initial startup, then labeled as part of the text area when
+@@ -220,7 +220,7 @@
+ #endif
+
+ #ifndef LIB_X11_LIB
+-#define LIB_X11_LIB -lX11
++#define LIB_X11_LIB -L/usr/X11R6/lib -lX11
+ #endif
+
+ #ifdef HAVE_X_WINDOWS
+@@ -258,7 +258,7 @@
+ GNULIB_VAR = `if [ -f LIB_GCC ] ; then echo LIB_GCC; else echo; fi`
+ #endif /* __GNUC__ <= 1 */
+ #else
+-GNULIB_VAR =
++GNULIB_VAR =
+ #endif
+
+ #ifdef MAINTAIN_ENVIRONMENT
+@@ -284,11 +284,12 @@
+ process.o callproc.o $(environobj) \
+ doprnt.o
+
++#define TERMINFO
+ #ifdef TERMINFO
+ /* Used to be -ltermcap here. If your machine needs that,
+ define LIBS_TERMCAP in the m- file. */
+ #ifndef LIBS_TERMCAP
+-#define LIBS_TERMCAP -lcurses
++#define LIBS_TERMCAP -lncurses
+ #endif
+ termcapobj = terminfo.o
+ #else
+@@ -460,51 +461,51 @@
+ it is so often changed in ways that do not require any recompilation
+ and so rarely changed in ways that do require any. */
+
+-abbrev.o : abbrev.c buffer.h commands.h config.h
+-buffer.o : buffer.c syntax.h buffer.h commands.h window.h config.h
+-callint.o : callint.c window.h commands.h buffer.h config.h
+-callproc.o : callproc.c paths.h buffer.h commands.h config.h
+-casefiddle.o : casefiddle.c syntax.h commands.h buffer.h config.h
++abbrev.o : abbrev.c buffer.h commands.h config.h
++buffer.o : buffer.c syntax.h buffer.h commands.h window.h config.h
++callint.o : callint.c window.h commands.h buffer.h config.h
++callproc.o : callproc.c paths.h buffer.h commands.h config.h
++casefiddle.o : casefiddle.c syntax.h commands.h buffer.h config.h
+ cm.o : cm.c cm.h termhooks.h config.h
+-cmds.o : cmds.c syntax.h buffer.h commands.h config.h
++cmds.o : cmds.c syntax.h buffer.h commands.h config.h
+ crt0.o : crt0.c config.h
+ $(CC) -c $(CFLAGS) C_SWITCH_ASM crt0.c
+ dired.o : dired.c commands.h buffer.h config.h regex.h
+ dispnew.o : dispnew.c commands.h window.h buffer.h dispextern.h termchar.h termopts.h cm.h config.h lisp.h
+ doc.o : doc.c buffer.h config.h paths.h
+ doprnt.o : doprnt.c
+-editfns.o : editfns.c window.h buffer.h config.h
+-emacs.o : emacs.c commands.h config.h
++editfns.o : editfns.c window.h buffer.h config.h
++emacs.o : emacs.c commands.h config.h
+ #ifdef MAINTAIN_ENVIRONMENT
+ environ.o : environ.c buffer.h commands.h config.h
+ #endif /* MAINTAIN_ENVIRONMENT */
+-fileio.o : fileio.c window.h buffer.h config.h
++fileio.o : fileio.c window.h buffer.h config.h
+ filelock.o : filelock.c buffer.h paths.h config.h
+-filemode.o : filemode.c
++filemode.o : filemode.c
+ indent.o : indent.c window.h indent.h buffer.h config.h termchar.h termopts.h
+-insdel.o : insdel.c window.h buffer.h config.h
+-keyboard.o : keyboard.c termchar.h termhooks.h termopts.h buffer.h commands.h window.h macros.h config.h
+-keymap.o : keymap.c buffer.h commands.h config.h
+-lastfile.o : lastfile.c
++insdel.o : insdel.c window.h buffer.h config.h
++keyboard.o : keyboard.c termchar.h termhooks.h termopts.h buffer.h commands.h window.h macros.h config.h
++keymap.o : keymap.c buffer.h commands.h config.h
++lastfile.o : lastfile.c
+ macros.o : macros.c window.h buffer.h commands.h macros.h config.h
+ malloc.o : malloc.c config.h
+-marker.o : marker.c buffer.h config.h
+-minibuf.o : minibuf.c syntax.h window.h buffer.h commands.h config.h
++marker.o : marker.c buffer.h config.h
++minibuf.o : minibuf.c syntax.h window.h buffer.h commands.h config.h
+ mocklisp.o : mocklisp.c buffer.h config.h
+-process.o : process.c process.h buffer.h window.h termhooks.h termopts.h commands.h dispextern.h config.h
+-regex.o : regex.c syntax.h buffer.h config.h regex.h
++process.o : process.c process.h buffer.h window.h termhooks.h termopts.h commands.h dispextern.h config.h
++regex.o : regex.c syntax.h buffer.h config.h regex.h
+ scroll.o : scroll.c termchar.h config.h dispextern.h termhooks.h
+-search.o : search.c regex.h commands.h buffer.h syntax.h config.h
+-syntax.o : syntax.c syntax.h buffer.h commands.h config.h
++search.o : search.c regex.h commands.h buffer.h syntax.h config.h
++syntax.o : syntax.c syntax.h buffer.h commands.h config.h
+ sysdep.o : sysdep.c config.h dispextern.h termhooks.h termchar.h termopts.h window.h
+ term.o : term.c termchar.h termhooks.h termopts.h config.h cm.h
+ termcap.o : termcap.c config.h
+ terminfo.o : terminfo.c config.h
+ tparam.o : tparam.c config.h
+-undo.o : undo.c buffer.h commands.h config.h
++undo.o : undo.c buffer.h commands.h config.h
+ UNEXEC : config.h getpagesize.h
+ window.o : window.c indent.h commands.h window.h buffer.h config.h termchar.h
+-xdisp.o : xdisp.c macros.h commands.h indent.h buffer.h dispextern.h termchar.h window.h config.h
++xdisp.o : xdisp.c macros.h commands.h indent.h buffer.h dispextern.h termchar.h window.h config.h
+ xfns.o : xfns.c xterm.h window.h config.h
+ xmenu.o : xmenu.c xterm.h window.h config.h
+ xterm.o : xterm.c xterm.h termhooks.h termopts.h termchar.h \
+@@ -517,13 +518,13 @@
+
+ /* The files of Lisp proper */
+
+-alloc.o : alloc.c window.h buffer.h config.h
+-bytecode.o : bytecode.c buffer.h config.h
+-data.o : data.c buffer.h config.h
++alloc.o : alloc.c window.h buffer.h config.h
++bytecode.o : bytecode.c buffer.h config.h
++data.o : data.c buffer.h config.h
+ eval.o : eval.c commands.h config.h
+ fns.o : fns.c buffer.h commands.h config.h
+-print.o : print.c process.h window.h buffer.h dispextern.h termchar.h config.h
+-lread.o : lread.c buffer.h paths.h config.h
++print.o : print.c process.h window.h buffer.h dispextern.h termchar.h config.h
++lread.o : lread.c buffer.h paths.h config.h
+
+ /* System-specific programs to be made.
+ OTHER_FILES, OBJECTS_SYSTEM and OBJECTS_MACHINE