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