annotate src/unexcw.c @ 5630:f5315ccbf005

Cons less, be more careful about always using the environment, #'macroexpand 2011-12-30 Aidan Kehoe <kehoea@parhasard.net> * eval.c (Fmacroexpand): Don't cons if ENVIRONMENT is the same object as byte-compile-macro-environment. Always look up symbol- and other macros in the (possibly modified) byte-compile-macro-environment, not the supplied ENVIRONMENT. byte-compile-macro-environment reflects ENVIRONMENT, so that's OK and preferred.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 30 Dec 2011 12:43:52 +0000
parents 4dee0387b9de
children 574f0cded429
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 558
diff changeset
1 /* unexec for XEmacs on Cygwin32.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1998 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4854
diff changeset
6 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4854
diff changeset
8 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4854
diff changeset
9 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4854
diff changeset
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 /* This is a complete rewrite, some code snarfed from unexnt.c and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 unexec.c, Andy Piper (andy@xemacs.org) 13-1-98 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
22 #include <config.h>
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
23 #include "lisp.h"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
24
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "sysfile.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
26
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
27 #define PERROR(arg) \
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
28 do { \
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
29 perror (arg); \
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
30 exit (-1); \
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
31 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
33 #if !defined (HAVE_A_OUT_H) && !defined (WIN32_NATIVE)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 unexec (char *, char *, void *, void *, void *)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
36 PERROR ("cannot unexec() a.out.h not installed");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
40 #ifdef MINGW
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
41 #include <../../include/a.out.h>
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
42 #else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include <a.out.h>
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 462
diff changeset
44 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
1198
c1e69bcf8d07 [xemacs-hg @ 2003-01-10 14:12:40 by youngs]
youngs
parents: 1111
diff changeset
46 #define STACK_SIZE 0x800000
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #define ALLOC_UNIT 0xFFFF
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
48 #define ALLOC_MASK ~((unsigned long) (ALLOC_UNIT))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #define ALIGN_ALLOC(addr) \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
50 ((((unsigned long) addr) + ALLOC_UNIT) & ALLOC_MASK)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
51 /* Note that all sections must be aligned on a 0x1000 boundary so
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
52 this is the minimum size that our dummy bss can be. */
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
53 #ifndef NO_DEBUG
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
54 #define BSS_PAD_SIZE 0x1000
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
55 #else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
56 #define BSS_PAD_SIZE 0
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
57 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 /* To prevent zero-initialized variables from being placed into the bss
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 section, use non-zero values to represent an uninitialized state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #define UNINIT_PTR ((void *) 0xF0A0F0A0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #define UNINIT_LONG (0xF0A0F0A0L)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 static void get_section_info (int a_out, char* a_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 static void copy_executable_and_dump_data_section (int a_out, int a_new);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
66 static void dup_file_area (int a_out, int a_new, long size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #if 0
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
68 static void write_int_to_bss (int a_out, int a_new, void* va, void* newval);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 /* Cached info about the .data section in the executable. */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
72 void *data_start_va = UNINIT_PTR;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
73 long data_size = UNINIT_LONG;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 /* Cached info about the .bss section in the executable. */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
76 void *bss_start = UNINIT_PTR;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
77 long bss_size = UNINIT_LONG;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 int sections_reversed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 FILHDR f_hdr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 PEAOUTHDR f_ohdr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 SCNHDR f_data, f_bss, f_text, f_nextdata;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
1685
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
83 #define CHECK_AOUT_POS(a) \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
84 do { \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
85 if (lseek (a_out, 0, SEEK_CUR) != a) \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
86 { \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
87 printf ("we are at %lx, should be at %lx\n", \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
88 (unsigned long) lseek (a_out, 0, SEEK_CUR), \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
89 (unsigned long) (a)); \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
90 exit (-1); \
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
91 } \
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
92 } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 /* Dump out .data and .bss sections into a new executable. */
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
95 int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1685
diff changeset
96 unexec (char *out_name, char *in_name, uintptr_t UNUSED (start_data),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1685
diff changeset
97 uintptr_t UNUSED (d1), uintptr_t UNUSED (d2))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 /* ugly nt hack - should be in lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 int a_new, a_out = -1;
4854
95c4ced5c07c fix compile problems
Ben Wing <ben@xemacs.org>
parents: 4840
diff changeset
101 char new_name[PATH_MAX_TCHAR], a_name[PATH_MAX_TCHAR];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 /* Make sure that the input and output filenames have the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 ".exe" extension...patch them up if they don't. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 strcpy (a_name, in_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 ptr = a_name + strlen (a_name) - 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 if (strcmp (ptr, ".exe"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 strcat (a_name, ".exe");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 strcpy (new_name, out_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 ptr = new_name + strlen (new_name) - 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 if (strcmp (ptr, ".exe"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 strcat (new_name, ".exe");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 /* We need to round off our heap to NT's allocation unit (64KB). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 /* round_heap (get_allocation_unit ()); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 if (a_name && (a_out = open (a_name, O_RDONLY | OPEN_BINARY)) < 0)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
120 PERROR (a_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 if ((a_new = open (new_name, O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY,
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
123 0755)) < 0)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
124 PERROR (new_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 /* Get the interesting section info, like start and size of .bss... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 get_section_info (a_out, a_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 copy_executable_and_dump_data_section (a_out, a_new);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
131 close (a_out);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
132 close (a_new);
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
133 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 /* Flip through the executable and cache the info necessary for dumping. */
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
137 static void
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
138 get_section_info (int a_out, char* a_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 {
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
140 extern char my_ebss[];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 /* From lastfile.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 extern char my_edata[];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
145 PERROR (a_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 if (f_hdr.e_magic != DOSMAGIC)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
148 PERROR ("unknown exe header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 /* Check the NT header signature ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 if (f_hdr.nt_signature != NT_SIGNATURE)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
152 PERROR ("invalid nt header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* Flip through the sections for .data and .bss ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 if (f_hdr.f_opthdr > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 if (read (a_out, &f_ohdr, AOUTSZ) != AOUTSZ)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
158 PERROR (a_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* Loop through .data & .bss section headers, copying them in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 With newer lds these are reversed so we have to cope with both */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 lseek (a_out, sizeof (f_hdr) + f_hdr.f_opthdr, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 if (read (a_out, &f_text, sizeof (f_text)) != sizeof (f_text)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
165 || strcmp (f_text.s_name, ".text"))
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
166 PERROR ("no .text section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 /* The .bss section. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 if (read (a_out, &f_bss, sizeof (f_bss)) != sizeof (f_bss)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
170 || (strcmp (f_bss.s_name, ".bss") && strcmp (f_bss.s_name, ".data")))
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
171 PERROR ("no .bss / .data section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* check for reversed .bss and .data */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
174 if (!strcmp (f_bss.s_name, ".data"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
176 printf (".data and .bss reversed\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 sections_reversed = 1;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
178 memcpy (&f_data, &f_bss, sizeof (f_bss));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 /* The .data section. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (!sections_reversed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 if (read (a_out, &f_data, sizeof (f_data)) != sizeof (f_data)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
185 || strcmp (f_data.s_name, ".data"))
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
186 PERROR ("no .data section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 if (read (a_out, &f_bss, sizeof (f_bss)) != sizeof (f_bss)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
191 || strcmp (f_bss.s_name, ".bss"))
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
192 PERROR ("no .bss section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 bss_start = (void *) ((char*)f_ohdr.ImageBase + f_bss.s_vaddr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 bss_size = (unsigned long)((char*)&my_ebss-(char*)bss_start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 /* must keep bss data that we want to be blank as blank */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
199 printf ("found bss - keeping %lx of %lx bytes\n", bss_size, f_ohdr.bsize);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* The .data section. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 data_start_va = (void *) ((char*)f_ohdr.ImageBase + f_data.s_vaddr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 /* We want to only write Emacs data back to the executable,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 not any of the library data (if library data is included,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 then a dumped Emacs won't run on system versions other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 than the one Emacs was dumped on). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 data_size = (unsigned long)my_edata - (unsigned long)data_start_va;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
209 printf ("found data - keeping %lx of %lx bytes\n", data_size, f_ohdr.dsize);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 /* The following data section - often .idata */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 if (read (a_out, &f_nextdata, sizeof (f_nextdata)) != sizeof (f_nextdata)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
213 && strcmp (&f_nextdata.s_name[2], "data"))
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
214 PERROR ("no other data section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* The dump routines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 copy_executable_and_dump_data_section (int a_out, int a_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
222 long size = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
223 /* NOTE: Some of these were previously declared as unsigned long,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
224 but the ones changed to long represent file sizes or pointers,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
225 which can't reasonably get above 2G. (A 2G executable???)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
226 Furthermore, some were even being compared as in if (x < 0) ... */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
227 long new_data_size, new_bss_size, bss_padding, file_sz_change;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
228 long data_padding = 0;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
229 long f_data_s_scnptr = f_data.s_scnptr;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
230 long f_nextdata_s_scnptr = f_nextdata.s_scnptr;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
231 unsigned long f_data_s_vaddr = f_data.s_vaddr;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
232 unsigned long f_bss_s_vaddr = f_bss.s_vaddr;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 void* empty_space;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 extern int static_heap_dumped;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 SCNHDR section;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
238 /* calculate new sizes:
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
239
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
240 f_ohdr.dsize is the total initialized data size on disk which is
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
241 f_data.s_size + f_idata.s_size.
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
242
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 4854
diff changeset
243 f_ohdr.data_start is the base address of all data and so should
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
244 not be changed.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
245
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
246 *.s_vaddr is the virtual address of the start of the section
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
247 *normalized from f_ohdr.ImageBase.
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
248
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
249 *.s_paddr appears to be the number of bytes in the section
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
250 *actually used (whereas *.s_size is aligned).
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
251
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 bsize is now 0 since subsumed into .data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 dsize is dsize + (f_data.s_vaddr - f_bss.s_vaddr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 f_data.s_vaddr is f_bss.s_vaddr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 f_data.s_size is new dsize maybe.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 what about s_paddr & s_scnptr? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 /* this is the amount the file increases in size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 if (!sections_reversed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 new_bss_size = f_data.s_vaddr - f_bss.s_vaddr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 data_padding = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 new_bss_size = f_nextdata.s_vaddr - f_bss.s_vaddr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 data_padding = (f_bss.s_vaddr - f_data.s_vaddr) - f_data.s_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
270 if ((new_bss_size - bss_size) < BSS_PAD_SIZE)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
271 PERROR (".bss free space too small");
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
272
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
273 file_sz_change = (new_bss_size + data_padding) - BSS_PAD_SIZE;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
274 new_data_size = f_ohdr.dsize + file_sz_change;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 if (!sections_reversed)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
277 f_data.s_vaddr = f_bss.s_vaddr;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 f_data.s_paddr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 if (f_data.s_size + f_nextdata.s_size != f_ohdr.dsize)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
281 printf ("section size doesn't tally with dsize %lx != %lx\n",
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
282 f_data.s_size + f_nextdata.s_size, f_ohdr.dsize);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 f_data.s_size += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 lseek (a_new, 0, SEEK_SET);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 /* write file header */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 f_hdr.f_symptr += file_sz_change;
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
288 #ifdef NO_DEBUG
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
289 f_hdr.f_nscns--;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
290 #endif
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
291
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
292 printf ("writing file header\n");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
293 if (write (a_new, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
294 PERROR ("failed to write file header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 /* write optional header fixing dsize & bsize*/
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
296 printf ("writing optional header\n");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
297 printf ("new data size is %lx, >= %lx\n", new_data_size,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 f_ohdr.dsize + f_ohdr.bsize);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
299 if (new_data_size < (long) (f_ohdr.dsize + f_ohdr.bsize))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
300 printf ("warning: new data size is < approx\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 f_ohdr.dsize=new_data_size;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
302 f_ohdr.bsize=BSS_PAD_SIZE;
1198
c1e69bcf8d07 [xemacs-hg @ 2003-01-10 14:12:40 by youngs]
youngs
parents: 1111
diff changeset
303 /* Prevent stack overflow with regexp usage. */
c1e69bcf8d07 [xemacs-hg @ 2003-01-10 14:12:40 by youngs]
youngs
parents: 1111
diff changeset
304 f_ohdr.SizeOfStackReserve = STACK_SIZE;
c1e69bcf8d07 [xemacs-hg @ 2003-01-10 14:12:40 by youngs]
youngs
parents: 1111
diff changeset
305
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
306 if (write (a_new, &f_ohdr, sizeof (f_ohdr)) != sizeof (f_ohdr))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
307 PERROR ("failed to write optional header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 /* write text as is */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
309 printf ("writing text header (unchanged)\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
311 if (write (a_new, &f_text, sizeof (f_text)) != sizeof (f_text))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
312 PERROR ("failed to write text header");
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
313 #ifndef NO_DEBUG
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
314 /* Write small bss section. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
315 if (!sections_reversed)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
316 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
317 f_bss.s_size = BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
318 f_bss.s_paddr = BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
319 f_bss.s_vaddr = f_data.s_vaddr - BSS_PAD_SIZE;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
320 if (write (a_new, &f_bss, sizeof (f_bss)) != sizeof (f_bss))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
321 PERROR ("failed to write bss header");
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
322 }
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
323 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 /* write new data header */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
325 printf ("writing .data header\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
327 if (write (a_new, &f_data, sizeof (f_data)) != sizeof (f_data))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
328 PERROR ("failed to write data header");
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
329 #ifndef NO_DEBUG
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
330 /* Write small bss section. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
331 if (sections_reversed)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
332 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
333 f_bss.s_size = BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
334 f_bss.s_paddr = BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
335 f_bss.s_vaddr = f_nextdata.s_vaddr - BSS_PAD_SIZE;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
336 if (write (a_new, &f_bss, sizeof (f_bss)) != sizeof (f_bss))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
337 PERROR ("failed to write bss header");
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
338 }
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
339 #endif
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
340 printf ("writing following data header\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 f_nextdata.s_scnptr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 if (f_nextdata.s_lnnoptr != 0) f_nextdata.s_lnnoptr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 if (f_nextdata.s_relptr != 0) f_nextdata.s_relptr += file_sz_change;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
344 if (write (a_new, &f_nextdata, sizeof (f_nextdata)) != sizeof (f_nextdata))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
345 PERROR ("failed to write nextdata header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* copy other section headers adjusting the file offset */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 for (i=0; i<(f_hdr.f_nscns-3); i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 if (read (a_out, &section, sizeof (section)) != sizeof (section))
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
351 PERROR ("no .data section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 section.s_scnptr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 if (section.s_lnnoptr != 0) section.s_lnnoptr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 if (section.s_relptr != 0) section.s_relptr += file_sz_change;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
357 if (write (a_new, &section, sizeof (section)) != sizeof (section))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
358 PERROR ("failed to write data header");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 }
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
360 #ifdef NO_DEBUG
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
361 /* dump bss to maintain offsets */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
362 memset (&f_bss, 0, sizeof (f_bss));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
363 if (write (a_new, &f_bss, sizeof (f_bss)) != sizeof (f_bss))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
364 PERROR ("failed to write bss header");
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
365 #endif
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
366 size = lseek (a_new, 0, SEEK_CUR);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
367 CHECK_AOUT_POS (size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /* copy eveything else until start of data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 size = f_data_s_scnptr - lseek (a_out, 0, SEEK_CUR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 printf ("copying executable up to data section ... %lx bytes\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 size);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
374 dup_file_area (a_out, a_new, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
376 CHECK_AOUT_POS (f_data_s_scnptr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 if (!sections_reversed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
380 /* dump bss + padding between sections, sans small bss pad */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 printf ("dumping .bss into executable... %lx bytes\n", bss_size);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
382 if (write (a_new, bss_start, bss_size) != bss_size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
384 PERROR ("failed to write bss section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 /* pad, needs to be zero */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
388 bss_padding = (new_bss_size - bss_size) - BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
389 if (bss_padding < 0)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
390 PERROR ("padded .bss too small");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 printf ("padding .bss ... %lx bytes\n", bss_padding);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
392 empty_space = malloc (bss_padding);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
393 memset (empty_space, 0, bss_padding);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
394 if (write (a_new, empty_space, bss_padding) != bss_padding)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
395 PERROR ("failed to write bss section");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
396 free (empty_space);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 /* tell dumped version not to free pure heap */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 static_heap_dumped = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 /* Get a pointer to the raw data in our address space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 printf ("dumping .data section... %lx bytes\n", data_size);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
403 if (write (a_new, data_start_va, data_size) != data_size)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
404 PERROR ("failed to write data section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 /* were going to use free again ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 static_heap_dumped = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
408 size = lseek (a_out, f_data_s_scnptr + data_size, SEEK_SET);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 if (!sections_reversed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 size = f_nextdata_s_scnptr - size;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
413 dup_file_area (a_out, a_new, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
417 /* need to pad to bss with data in file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 printf ("padding .data ... %lx bytes\n", data_padding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 size = (f_bss_s_vaddr - f_data_s_vaddr) - data_size;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
420 dup_file_area (a_out, a_new, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* dump bss + padding between sections */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 printf ("dumping .bss into executable... %lx bytes\n", bss_size);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
424 if (write (a_new, bss_start, bss_size) != bss_size)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
425 PERROR ("failed to write bss section");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 /* pad, needs to be zero */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
428 bss_padding = (new_bss_size - bss_size) - BSS_PAD_SIZE;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
429 if (bss_padding < 0)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
430 PERROR ("padded .bss too small");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 printf ("padding .bss ... %lx bytes\n", bss_padding);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
432 empty_space = malloc (bss_padding);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
433 memset (empty_space, 0, bss_padding);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
434 if (write (a_new, empty_space, bss_padding) != bss_padding)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
435 PERROR ("failed to write bss section");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
436 free (empty_space);
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
437 if (lseek (a_new, 0, SEEK_CUR) != (long) f_nextdata.s_scnptr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
439 printf ("at %lx should be at %lx\n",
1685
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
440 (unsigned long) lseek (a_new, 0, SEEK_CUR),
29c45c1b64f3 [xemacs-hg @ 2003-09-15 21:19:11 by james]
james
parents: 1198
diff changeset
441 (unsigned long) f_nextdata.s_scnptr);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
442 PERROR ("file positioning error\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 }
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
444 lseek (a_out, f_nextdata_s_scnptr, SEEK_SET);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
447 CHECK_AOUT_POS (f_nextdata_s_scnptr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 /* now dump - nextdata don't need to do this cygwin ds is in .data! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 printf ("dumping following data section... %lx bytes\n", f_nextdata.s_size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
452 dup_file_area (a_out,a_new,f_nextdata.s_size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 /* write rest of file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 printf ("writing rest of file\n");
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
456 size = lseek (a_out, 0, SEEK_END);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 size = size - (f_nextdata_s_scnptr + f_nextdata.s_size); /* length remaining in a_out */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
458 lseek (a_out, f_nextdata_s_scnptr + f_nextdata.s_size, SEEK_SET);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
460 dup_file_area (a_out, a_new, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 * copy from aout to anew
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
466 static void
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
467 dup_file_area (int a_out, int a_new, long size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 char page[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 long n;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 for (; size > 0; size -= sizeof (page))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 {
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 771
diff changeset
473 n = size > (long) sizeof (page) ? (long) sizeof (page) : size;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 if (read (a_out, page, n) != n || write (a_new, page, n) != n)
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
475 PERROR ("dump_out()");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 #if 0
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
480 static void
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
481 write_int_to_bss (int a_out, int a_new, void* va, void* newval)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 int cpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
485 cpos = lseek (a_new, 0, SEEK_CUR);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 if (va < bss_start || va > bss_start + f_data.s_size)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
487 PERROR ("address not in data space\n");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
488 lseek (a_new, f_data.s_scnptr + ((unsigned long)va -
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (unsigned long)bss_start), SEEK_SET);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
490 if (write (a_new, newval, sizeof (int)) != (int) sizeof (int))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
491 PERROR ("failed to write int value");
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 613
diff changeset
492 lseek (a_new, cpos, SEEK_SET);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 #endif /* HAVE_A_OUT_H */