* A_TEXT_SEEK(HDR)
If defined, this macro specifies the number of bytes to seek into the
-a.out file before starting to write the text segment.a
+a.out file before starting to write the text segment.
* EXEC_MAGIC
#include <sys/stat.h>
#include <errno.h>
+#include <sys/file.h> /* Must be after sys/types.h for USG and BSD4_1*/
+
+#ifdef USG5
+#include <fcntl.h>
+#endif
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+#ifndef O_RDWR
+#define O_RDWR 2
+#endif
+
+
extern char *start_of_text (); /* Start of text */
extern char *start_of_data (); /* Start of initialized data */
#ifdef emacs
+#include "lisp.h"
+
static
report_error (file, fd)
char *file;
{
if (fd)
close (fd);
- error ("Failure operating on %s\n", file);
+ report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil));
}
#endif /* emacs */
{
int new, a_out = -1;
- if (a_name && (a_out = open (a_name, 0)) < 0)
+ if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
{
PERROR (a_name);
}
PERROR (new_name);
}
+ /* This adjustment was done above only #ifndef NO_REMAP,
+ so only undo it now #ifndef NO_REMAP. */
+#ifndef NO_REMAP
#ifdef A_TEXT_OFFSET
hdr.a_text -= A_TEXT_OFFSET (ohdr);
+#endif
#endif
return 0;
#ifdef MSDOS
if ((new = writedesc) < 0)
#else
- if ((new = open (new_name, 2)) < 0)
+ if ((new = open (new_name, O_RDWR)) < 0)
#endif
{
PERROR (new_name);