/* unexec() support for Cygwin;
complete rewrite of xemacs Cygwin unexec() code
- Copyright (C) 2004-2013 Free Software Foundation, Inc.
+ Copyright (C) 2004-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include "unexec.h"
+#include "lisp.h"
-#include <lisp.h>
#include <stdio.h>
#include <fcntl.h>
#include <a.out.h>
extern int bss_sbrk_did_unexec;
-extern int __malloc_initialized;
-
-/* emacs symbols that indicate where bss and data end for emacs internals */
-extern char my_endbss[];
-extern char my_edata[];
-
/*
** header for Windows executable files
*/
#endif
assert (exe_header_buffer->file_header.f_nscns > 0);
assert (exe_header_buffer->file_header.f_nscns <=
- sizeof (exe_header_buffer->section_header) /
- sizeof (exe_header_buffer->section_header[0]));
+ ARRAYELTS (exe_header_buffer->section_header));
assert (exe_header_buffer->file_header.f_opthdr > 0);
ret =
lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
SEEK_SET);
assert (ret != -1);
- /* force the dumped emacs to reinitialize malloc */
- __malloc_initialized = 0;
ret =
write (fd, (char *) start_address,
my_endbss - (char *) start_address);
- __malloc_initialized = 1;
assert (ret == (my_endbss - (char *) start_address));
if (debug_unexcw)
printf (" .bss, mem start %#lx mem length %d\n",
int ret;
int ret2;
- if (bss_sbrk_did_unexec)
- {
- /* can only dump once */
- printf ("You can only dump Emacs once on this platform.\n");
- return;
- }
-
report_sheap_usage (1);
infile = add_exe_suffix_if_necessary (infile, infile_buffer);
outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
- fd_in = open (infile, O_RDONLY | O_BINARY);
+ fd_in = emacs_open (infile, O_RDONLY | O_BINARY, 0);
assert (fd_in >= 0);
- fd_out = open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
+ fd_out = emacs_open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
assert (fd_out >= 0);
for (;;)
{
ret2 = write (fd_out, buffer, ret);
assert (ret2 == ret);
}
- ret = close (fd_in);
+ ret = emacs_close (fd_in);
assert (ret == 0);
bss_sbrk_did_unexec = 1;
fixup_executable (fd_out);
bss_sbrk_did_unexec = 0;
- ret = close (fd_out);
+ ret = emacs_close (fd_out);
assert (ret == 0);
}