annotate src/unexcw.c @ 110321:4b26adbef9a2

Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el. * Makefile.in (TRAMP_SRC): Remove tramp-fish.el. Add tramp-sh.el. * net/tramp.el (top): Don't show loading message. Require just 'tramp-compat, everything else is required there. Use `ignore-errors' where appropriate. (tramp-inline-compress-start-size, tramp-copy-size-limit) (tramp-terminal-type, tramp-end-of-output) (tramp-initial-end-of-output, tramp-completion-function-alist-rsh) (tramp-completion-function-alist-ssh) (tramp-completion-function-alist-telnet) (tramp-completion-function-alist-su) (tramp-completion-function-alist-putty, tramp-remote-path) (tramp-remote-process-environment, tramp-sh-extra-args) (tramp-actions-before-shell, tramp-uudecode) (tramp-perl-file-truename, tramp-perl-file-name-all-completions) (tramp-perl-file-attributes) (tramp-perl-directory-files-and-attributes) (tramp-perl-encode-with-module, tramp-perl-decode-with-module) (tramp-perl-encode, tramp-perl-decode) (tramp-vc-registered-read-file-names, tramp-file-mode-type-map) (tramp-file-name-handler-alist, tramp-make-tramp-temp-file) (tramp-handle-make-symbolic-link, tramp-handle-load) (tramp-handle-file-name-as-directory) (tramp-handle-file-name-directory) (tramp-handle-file-name-nondirectory, tramp-handle-file-truename) (tramp-handle-file-exists-p, tramp-handle-file-attributes) (tramp-do-file-attributes-with-ls) (tramp-do-file-attributes-with-perl) (tramp-do-file-attributes-with-stat) (tramp-handle-set-visited-file-modtime) (tramp-handle-verify-visited-file-modtime) (tramp-handle-set-file-modes, tramp-handle-set-file-times) (tramp-set-file-uid-gid, tramp-remote-selinux-p) (tramp-handle-file-selinux-context) (tramp-handle-set-file-selinux-context) (tramp-handle-file-executable-p, tramp-handle-file-readable-p) (tramp-handle-file-newer-than-file-p, tramp-handle-file-modes) (tramp-handle-file-directory-p, tramp-handle-file-regular-p) (tramp-handle-file-symlink-p, tramp-handle-file-writable-p) (tramp-handle-file-ownership-preserved-p) (tramp-handle-directory-file-name, tramp-handle-directory-files) (tramp-handle-directory-files-and-attributes) (tramp-do-directory-files-and-attributes-with-perl) (tramp-do-directory-files-and-attributes-with-stat) (tramp-handle-file-name-all-completions) (tramp-handle-file-name-completion, tramp-handle-add-name-to-file) (tramp-handle-copy-file, tramp-handle-copy-directory) (tramp-handle-rename-file, tramp-do-copy-or-rename-file) (tramp-do-copy-or-rename-file-via-buffer) (tramp-do-copy-or-rename-file-directly) (tramp-do-copy-or-rename-file-out-of-band) (tramp-handle-make-directory, tramp-handle-delete-directory) (tramp-handle-delete-file) (tramp-handle-dired-recursive-delete-directory) (tramp-handle-dired-compress-file, tramp-handle-dired-uncache) (tramp-handle-insert-directory) (tramp-handle-unhandled-file-name-directory) (tramp-handle-expand-file-name) (tramp-handle-substitute-in-file-name) (tramp-handle-executable-find, tramp-process-sentinel) (tramp-handle-start-file-process, tramp-handle-process-file) (tramp-handle-call-process-region, tramp-handle-shell-command) (tramp-handle-file-local-copy, tramp-handle-file-remote-p) (tramp-handle-insert-file-contents) (tramp-handle-insert-file-contents-literally) (tramp-handle-find-backup-file-name) (tramp-handle-make-auto-save-file-name, tramp-handle-write-region) (tramp-vc-registered-file-names, tramp-handle-vc-registered) (tramp-sh-file-name-handler, tramp-vc-file-name-handler) (tramp-maybe-send-script, tramp-set-auto-save, tramp-run-test) (tramp-run-test2, tramp-find-executable, tramp-set-remote-path) (tramp-find-file-exists-command, tramp-open-shell) (tramp-find-shell, tramp-barf-if-no-shell-prompt) (tramp-open-connection-setup-interactive-shell) (tramp-local-coding-commands, tramp-remote-coding-commands) (tramp-find-inline-encoding, tramp-call-local-coding-command) (tramp-inline-compress-commands, tramp-find-inline-compress) (tramp-compute-multi-hops, tramp-maybe-open-connection) (tramp-send-command , tramp-wait-for-output) (tramp-send-command-and-check, tramp-barf-unless-okay) (tramp-send-command-and-read, tramp-mode-string-to-int) (tramp-convert-file-attributes, tramp-check-cached-permissions) (tramp-file-mode-from-int, tramp-file-mode-permissions) (tramp-shell-case-fold, tramp-make-copy-program-file-name) (tramp-method-out-of-band-p, tramp-local-host-p) (tramp-get-remote-path, tramp-get-remote-tmpdir) (tramp-get-ls-command, tramp-get-ls-command-with-dired) (tramp-get-test-command, tramp-get-test-nt-command) (tramp-get-file-exists-command, tramp-get-remote-ln) (tramp-get-remote-perl, tramp-get-remote-stat) (tramp-get-remote-readlink, tramp-get-remote-trash) (tramp-get-remote-id, tramp-get-remote-uid, tramp-get-remote-gid) (tramp-get-local-uid, tramp-get-local-gid) (tramp-get-inline-compress, tramp-get-inline-coding, ): Move to tramp-sh.el. (tramp-methods, tramp-default-method-alist) (tramp-default-user-alist, tramp-foreign-file-name-handler-alist): Move initialization to tramp-sh.el. (tramp-temp-name-prefix): Make it a defconst. (tramp-dissect-file-name): Don't check anymore for multi-hop methods. (tramp-debug-outline-regexp): Add a docstring. (tramp-debug-outline-level): Renamed from `tramp-outline-level'. (tramp-get-debug-buffer): Use it. * net/tramp-cache.el (top): Set tramp-autoload cookie for initialization forms. (tramp-set-connection-property): Don't protect `tramp-message' call, it isn't necessary any longer. (tramp-dump-connection-properties): Use `ignore-errors'. * net/tramp-compat.el (top): Require 'advice, 'format-spec, 'password-cache and 'auth-source. * net/tramp-gvfs.el (top): * net/tramp-smb.el (top): Require 'tramp-sh. * net/tramp-gw.el (tramp-gw-open-network-stream): Use `ignore-errors'. * net/tramp-sh.el: New file, derived from tramp.el. (top): Initialize `tramp-methods', `tramp-default-method-alist', `tramp-default-user-alist', tramp-foreign-file-name-handler-alist. Remove "scp1_old", "scp2_old", "ssh1_old", "ssh2_old". Use `ignore-errors' where appropriate. (tramp-sh-file-name-handler-alist): Renamed from `tramp-file-name-handler-alist'. (tramp-send-command-and-check): Return t or nil. Remove all `zerop' checks, where called. (tramp-handle-set-file-modes) (tramp-do-copy-or-rename-file-directly) (tramp-handle-delete-directory, tramp-handle-delete-file) (tramp-maybe-send-script, ): Use `tramp-barf-unless-okay'. (tramp-sh-file-name-handler, tramp-send-command-and-check) (tramp-get-remote-ln): Set tramp-autoload cookie. * net/tramp-fish.el: Remove file.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 13 Sep 2010 17:17:01 +0200
parents 1d1d5d9bd884
children 99084f50aa8e 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 /* unexec() support for Cygwin;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2 complete rewrite of xemacs Cygwin unexec() code
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
3
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 This file is part of GNU Emacs.
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79759
diff changeset
8 GNU Emacs is free software: you can redistribute it and/or modify
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79759
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79759
diff changeset
11 (at your option) any later version.
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 GNU Emacs is distributed in the hope that it will be useful,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 GNU General Public License for more details.
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79759
diff changeset
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 #include <config.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100951
diff changeset
22 #include <setjmp.h>
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 #include <lisp.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24 #include <stdio.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25 #include <fcntl.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26 #include <a.out.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 #include <unistd.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 #include <assert.h>
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 #define DOTEXE ".exe"
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 extern int bss_sbrk_did_unexec;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 /* emacs symbols that indicate where bss and data end for emacs internals */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 extern char my_endbss[];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 extern char my_edata[];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 /*
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 ** header for Windows executable files
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 typedef struct
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 FILHDR file_header;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 PEAOUTHDR file_optional_header;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 SCNHDR section_header[32];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 } exe_header_t;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 int debug_unexcw = 0;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 /*
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 ** Read the header from the executable into memory so we can more easily access it.
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 static exe_header_t *
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 read_exe_header (int fd, exe_header_t * exe_header_buffer)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 int i;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 int ret;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 assert (fd >= 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 assert (exe_header_buffer != 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 ret = lseek (fd, 0L, SEEK_SET);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 read (fd, &exe_header_buffer->file_header,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 sizeof (exe_header_buffer->file_header));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 assert (ret == sizeof (exe_header_buffer->file_header));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 assert (exe_header_buffer->file_header.nt_signature == 0x4550);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 assert (exe_header_buffer->file_header.f_magic == 0x014c);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 assert (exe_header_buffer->file_header.f_nscns > 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 assert (exe_header_buffer->file_header.f_nscns <=
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 sizeof (exe_header_buffer->section_header) /
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 sizeof (exe_header_buffer->section_header[0]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 assert (exe_header_buffer->file_header.f_opthdr > 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 read (fd, &exe_header_buffer->file_optional_header,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 sizeof (exe_header_buffer->file_optional_header));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 assert (ret == sizeof (exe_header_buffer->file_optional_header));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 assert (exe_header_buffer->file_optional_header.magic == 0x010b);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 read (fd, &exe_header_buffer->section_header[i],
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 sizeof (exe_header_buffer->section_header[i]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 assert (ret == sizeof (exe_header_buffer->section_header[i]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 return (exe_header_buffer);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 /*
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 ** Fix the dumped emacs executable:
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 **
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 ** - copy .data section data of interest from running executable into
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 ** output .exe file
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 **
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 ** - convert .bss section into an initialized data section (like
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 ** .data) and copy .bss section data of interest from running
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 ** executable into output .exe file
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 static void
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 fixup_executable (int fd)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 exe_header_t exe_header_buffer;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 exe_header_t *exe_header;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 int i;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 int ret;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 int found_data = 0;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 int found_bss = 0;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 exe_header = read_exe_header (fd, &exe_header_buffer);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 assert (exe_header != 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 assert (exe_header->file_header.f_nscns > 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 for (i = 0; i < exe_header->file_header.f_nscns; ++i)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 unsigned long start_address =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 exe_header->section_header[i].s_vaddr +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 exe_header->file_optional_header.ImageBase;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 unsigned long end_address =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 exe_header->section_header[i].s_vaddr +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 exe_header->file_optional_header.ImageBase +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 exe_header->section_header[i].s_paddr;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 printf ("%8s start 0x%08x end 0x%08x\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 exe_header->section_header[i].s_name,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 start_address, end_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 if (my_edata >= (char *) start_address
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 && my_edata < (char *) end_address)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 /* data section */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 SEEK_SET);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 write (fd, (char *) start_address,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 my_edata - (char *) start_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 assert (ret == my_edata - (char *) start_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 ++found_data;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 printf (" .data, mem start 0x%08x mem length %d\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 start_address, my_edata - (char *) start_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 printf (" .data, file start %d file length %d\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 (int) exe_header->section_header[i].s_scnptr,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 (int) exe_header->section_header[i].s_paddr);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 else if (my_endbss >= (char *) start_address
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 && my_endbss < (char *) end_address)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 /* bss section */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 ++found_bss;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 if (exe_header->section_header[i].s_flags & 0x00000080)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 /* convert uninitialized data section to initialized data section */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 struct stat statbuf;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 ret = fstat (fd, &statbuf);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 exe_header->section_header[i].s_flags &= ~0x00000080;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 exe_header->section_header[i].s_flags |= 0x00000040;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 exe_header->section_header[i].s_scnptr =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 (statbuf.st_size +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 exe_header->file_optional_header.FileAlignment) /
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 exe_header->file_optional_header.FileAlignment *
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 exe_header->file_optional_header.FileAlignment;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 exe_header->section_header[i].s_size =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 (exe_header->section_header[i].s_paddr +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 exe_header->file_optional_header.FileAlignment) /
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 exe_header->file_optional_header.FileAlignment *
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 exe_header->file_optional_header.FileAlignment;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 lseek (fd,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 (long) (exe_header->section_header[i].s_scnptr +
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 exe_header->section_header[i].s_size - 1),
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 SEEK_SET);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 ret = write (fd, "", 1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 assert (ret == 1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 lseek (fd,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 (long) ((char *) &exe_header->section_header[i] -
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 (char *) exe_header), SEEK_SET);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 write (fd, &exe_header->section_header[i],
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 sizeof (exe_header->section_header[i]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 assert (ret == sizeof (exe_header->section_header[i]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 printf (" seek to %ld, write %d\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 (long) ((char *) &exe_header->section_header[i] -
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 (char *) exe_header),
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 sizeof (exe_header->section_header[i]));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 /* write initialized data section */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 SEEK_SET);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 assert (ret != -1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 ret =
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 write (fd, (char *) start_address,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 my_endbss - (char *) start_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 assert (ret == (my_endbss - (char *) start_address));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 printf (" .bss, mem start 0x%08x mem length %d\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 start_address, my_endbss - (char *) start_address);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 if (debug_unexcw)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 printf (" .bss, file start %d file length %d\n",
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 (int) exe_header->section_header[i].s_scnptr,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 (int) exe_header->section_header[i].s_paddr);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 assert (found_bss == 1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 assert (found_data == 1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 /*
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 ** Windows likes .exe suffixes on executables.
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 static char *
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 add_exe_suffix_if_necessary (const char *name, char *modified)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 int i = strlen (name);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 if (i <= (sizeof (DOTEXE) - 1))
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 sprintf (modified, "%s%s", name, DOTEXE);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 else if (!strcasecmp (name + i - (sizeof (DOTEXE) - 1), DOTEXE))
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 strcpy (modified, name);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 else
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 sprintf (modified, "%s%s", name, DOTEXE);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 return (modified);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 int
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 unexec (char *outfile, char *infile, unsigned start_data, unsigned d1,
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 unsigned d2)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 char infile_buffer[FILENAME_MAX];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 char outfile_buffer[FILENAME_MAX];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 int fd_in;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 int fd_out;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 int ret;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259 int ret2;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 if (bss_sbrk_did_unexec)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 /* can only dump once */
73688
f5b44958a759 (unexec): Fix typo in output message.
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
264 printf ("You can only dump Emacs once on this platform.\n");
54844
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 return (1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 report_sheap_usage (1);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 infile = add_exe_suffix_if_necessary (infile, infile_buffer);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 fd_in = open (infile, O_RDONLY | O_BINARY);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 assert (fd_in >= 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 fd_out = open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 assert (fd_out >= 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 for (;;)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 char buffer[4096];
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
280 ret = read (fd_in, buffer, sizeof (buffer));
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 if (ret == 0)
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 {
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 /* eof */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 break;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 assert (ret > 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 /* data */
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 ret2 = write (fd_out, buffer, ret);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 assert (ret2 == ret);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 }
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 ret = close (fd_in);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 assert (ret == 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 bss_sbrk_did_unexec = 1;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 fixup_executable (fd_out);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 bss_sbrk_did_unexec = 0;
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 ret = close (fd_out);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 assert (ret == 0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
301 return (0);
36dec396c129 New file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 }
54858
44a3fff23885 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 54844
diff changeset
303
44a3fff23885 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 54844
diff changeset
304 /* arch-tag: fc44f6c3-ca0a-45e0-a5a2-58b6101b1e65
44a3fff23885 Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 54844
diff changeset
305 (do not change this comment) */