HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove `declare' macro
[bpt/emacs.git]
/
src
/
unexcw.c
diff --git
a/src/unexcw.c
b/src/unexcw.c
index
af93e15
..
7636b05
100644
(file)
--- a/
src/unexcw.c
+++ b/
src/unexcw.c
@@
-1,7
+1,7
@@
/* unexec() support for Cygwin;
complete rewrite of xemacs Cygwin unexec() code
/* unexec() support for Cygwin;
complete rewrite of xemacs Cygwin unexec() code
- Copyright (C) 2004-201
3
Free Software Foundation, Inc.
+ Copyright (C) 2004-201
4
Free Software Foundation, Inc.
This file is part of GNU Emacs.
This file is part of GNU Emacs.
@@
-20,9
+20,8
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "unexec.h"
#include <config.h>
#include "unexec.h"
-#include "
w32common
.h"
+#include "
lisp
.h"
-#include <lisp.h>
#include <stdio.h>
#include <fcntl.h>
#include <a.out.h>
#include <stdio.h>
#include <fcntl.h>
#include <a.out.h>
@@
-31,6
+30,8
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define DOTEXE ".exe"
#define DOTEXE ".exe"
+extern void report_sheap_usage (int);
+
extern int bss_sbrk_did_unexec;
extern int __malloc_initialized;
extern int bss_sbrk_did_unexec;
extern int __malloc_initialized;
@@
-73,11
+74,14
@@
read_exe_header (int fd, exe_header_t * exe_header_buffer)
assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
assert (exe_header_buffer->file_header.nt_signature == 0x4550);
assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
assert (exe_header_buffer->file_header.nt_signature == 0x4550);
+#ifdef __x86_64__
+ assert (exe_header_buffer->file_header.f_magic == 0x8664);
+#else
assert (exe_header_buffer->file_header.f_magic == 0x014c);
assert (exe_header_buffer->file_header.f_magic == 0x014c);
+#endif
assert (exe_header_buffer->file_header.f_nscns > 0);
assert (exe_header_buffer->file_header.f_nscns <=
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 =
assert (exe_header_buffer->file_header.f_opthdr > 0);
ret =
@@
-85,7
+89,11
@@
read_exe_header (int fd, exe_header_t * exe_header_buffer)
sizeof (exe_header_buffer->file_optional_header));
assert (ret == sizeof (exe_header_buffer->file_optional_header));
sizeof (exe_header_buffer->file_optional_header));
assert (ret == sizeof (exe_header_buffer->file_optional_header));
+#ifdef __x86_64__
+ assert (exe_header_buffer->file_optional_header.magic == 0x020b);
+#else
assert (exe_header_buffer->file_optional_header.magic == 0x010b);
assert (exe_header_buffer->file_optional_header.magic == 0x010b);
+#endif
for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
{
for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
{
@@
-132,7
+140,7
@@
fixup_executable (int fd)
exe_header->file_optional_header.ImageBase +
exe_header->section_header[i].s_paddr;
if (debug_unexcw)
exe_header->file_optional_header.ImageBase +
exe_header->section_header[i].s_paddr;
if (debug_unexcw)
- printf ("%8s start
0x%08x end 0x%08
x\n",
+ printf ("%8s start
%#lx end %#l
x\n",
exe_header->section_header[i].s_name,
start_address, end_address);
if (my_edata >= (char *) start_address
exe_header->section_header[i].s_name,
start_address, end_address);
if (my_edata >= (char *) start_address
@@
-149,7
+157,7
@@
fixup_executable (int fd)
assert (ret == my_edata - (char *) start_address);
++found_data;
if (debug_unexcw)
assert (ret == my_edata - (char *) start_address);
++found_data;
if (debug_unexcw)
- printf (" .data, mem start
0x%08
x mem length %d\n",
+ printf (" .data, mem start
%#l
x mem length %d\n",
start_address, my_edata - (char *) start_address);
if (debug_unexcw)
printf (" .data, file start %d file length %d\n",
start_address, my_edata - (char *) start_address);
if (debug_unexcw)
printf (" .data, file start %d file length %d\n",
@@
-233,7
+241,7
@@
fixup_executable (int fd)
__malloc_initialized = 1;
assert (ret == (my_endbss - (char *) start_address));
if (debug_unexcw)
__malloc_initialized = 1;
assert (ret == (my_endbss - (char *) start_address));
if (debug_unexcw)
- printf (" .bss, mem start
0x%08
x mem length %d\n",
+ printf (" .bss, mem start
%#l
x mem length %d\n",
start_address, my_endbss - (char *) start_address);
if (debug_unexcw)
printf (" .bss, file start %d file length %d\n",
start_address, my_endbss - (char *) start_address);
if (debug_unexcw)
printf (" .bss, file start %d file length %d\n",
@@
-277,21
+285,14
@@
unexec (const char *outfile, const char *infile)
int ret;
int ret2;
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);
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);
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 (;;)
{
assert (fd_out >= 0);
for (;;)
{
@@
-307,13
+308,13
@@
unexec (const char *outfile, const char *infile)
ret2 = write (fd_out, buffer, ret);
assert (ret2 == ret);
}
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;
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);
}
assert (ret == 0);
}