]> code.delx.au - gnu-emacs/blobdiff - src/unexec.c
(PENDING_OUTPUT_COUNT) [__GNU_LIBRARY__]: Alternate definition for the GNU
[gnu-emacs] / src / unexec.c
index c1dc6e33016a261c2d085c313e48111c1a96bc48..e9be7aeac22eba09d1be957b4b4585a362ecc76d 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (C) 1985, 1986, 1987, 1988, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993 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)
+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,
@@ -164,7 +164,7 @@ pointer looks like an int) but not on all machines.
 #define PERROR(arg) perror (arg); return -1
 #else
 #define IN_UNEXEC
-#include "config.h"
+#include <config.h>
 #define PERROR(file) report_error (file, new)
 #endif
 
@@ -207,11 +207,22 @@ static long data_scnptr;
 
 #else /* not COFF */
 
+#ifdef HPUX
+extern void *sbrk ();
+#else
+#if 0
+/* Some systems with __STDC__ compilers still declare this `char *' in some
+   header file, and our declaration conflicts.  The return value is always
+   cast, so it should be harmless to leave it undefined.  Hopefully
+   machines with different size pointers and ints declare sbrk in a header
+   file.  */
 #ifdef __STDC__
 extern void *sbrk ();
 #else
 extern char *sbrk ();
+#endif /* __STDC__ */
 #endif
+#endif /* HPUX */
 
 #define SYMS_START ((long) N_SYMOFF (ohdr))
 
@@ -235,7 +246,7 @@ static EXEC_HDR_TYPE hdr, ohdr;
 
 #else /* not HPUX */
 
-#if defined (USG) && !defined (IBMAIX) && !defined (IRIS) && !defined (COFF_ENCAPSULATE)
+#if defined (USG) && !defined (IBMAIX) && !defined (IRIS) && !defined (COFF_ENCAPSULATE) && !defined (LINUX)
 static struct bhdr hdr, ohdr;
 #define a_magic fmagic
 #define a_text tsize
@@ -479,7 +490,7 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
    * space.
    */
 
-  bias = bss_end - (f_ohdr.data_start + f_dhdr.s_size);
+  bias = bss_start - (f_ohdr.data_start + f_dhdr.s_size);
 
 #endif
 
@@ -603,7 +614,7 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
    * .lib), adjust the address of where the section data is in the
    * file, and write out the header.
    *
-   * If any section preceeds .text or .data in the file, this code
+   * If any section precedes .text or .data in the file, this code
    * will not adjust the file pointer for that section correctly.
    */
 
@@ -675,7 +686,7 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
        */
       ERROR0 ("can't build a COFF file from scratch yet");
 #else
-      bzero (hdr, sizeof hdr);
+      bzero (&hdr, sizeof hdr);
 #endif
     }
 
@@ -808,7 +819,7 @@ copy_text_and_data (new, a_out)
            {
              n = size > sizeof (page) ? sizeof (page) : size;
              if (read (a_out, page, n) != n || write (new, page, n) != n)
-               PERROR ("xemacs");
+               PERROR ("emacs");
            }
          lseek (a_out, old_a_out_ptr, 0);
        }
@@ -946,7 +957,7 @@ copy_sym (new, a_out, a_name, new_name)
 /* ****************************************************************
  * mark_x
  *
- * After succesfully building the new a.out, mark it executable
+ * After successfully building the new a.out, mark it executable
  */
 static void
 mark_x (name)
@@ -1024,11 +1035,12 @@ adjust_lnnoptrs (writedesc, readdesc, new_name)
        {
          read (new, &auxentry, AUXESZ);
          nsyms++;
-         if (ISFCN (symentry.n_type)) {
-           auxentry.x_sym.x_fcnary.x_fcn.x_lnnoptr += bias;
-           lseek (new, -AUXESZ, 1);
-           write (new, &auxentry, AUXESZ);
-         }
+         if (ISFCN (symentry.n_type) || symentry.n_type == 0x2400)
+           {
+             auxentry.x_sym.x_fcnary.x_fcn.x_lnnoptr += bias;
+             lseek (new, -AUXESZ, 1);
+             write (new, &auxentry, AUXESZ);
+           }
        }
     }
   close (new);