Mercurial > hg > xemacs-beta
comparison src/unexec.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
134 structure HDR and return the number of bytes to add to `a_text' | 134 structure HDR and return the number of bytes to add to `a_text' |
135 before writing it (above and beyond the number of bytes of actual | 135 before writing it (above and beyond the number of bytes of actual |
136 program text). HDR's standard fields are already correct, except that | 136 program text). HDR's standard fields are already correct, except that |
137 this adjustment to the `a_text' field has not yet been made; | 137 this adjustment to the `a_text' field has not yet been made; |
138 thus, the amount of offset can depend on the data in the file. | 138 thus, the amount of offset can depend on the data in the file. |
139 | 139 |
140 * A_TEXT_SEEK(HDR) | 140 * A_TEXT_SEEK(HDR) |
141 | 141 |
142 If defined, this macro specifies the number of bytes to seek into the | 142 If defined, this macro specifies the number of bytes to seek into the |
143 a.out file before starting to write the text segment. | 143 a.out file before starting to write the text segment. |
144 | 144 |
184 /* I don't know how correct this attempt to get more prototypes is... */ | 184 /* I don't know how correct this attempt to get more prototypes is... */ |
185 # if defined(sun) && defined(_POSIX_SOURCE) | 185 # if defined(sun) && defined(_POSIX_SOURCE) |
186 # undef _POSIX_SOURCE | 186 # undef _POSIX_SOURCE |
187 # endif | 187 # endif |
188 | 188 |
189 # if defined(__lucid) && !defined(__STDC_EXTENDED__) | |
190 # define __STDC_EXTENDED__ 1 | |
191 # endif | |
192 | |
193 # include <stddef.h> | 189 # include <stddef.h> |
194 # include <stdlib.h> | 190 # include <stdlib.h> |
195 # include <unistd.h> | 191 # include <unistd.h> |
196 # include <string.h> | 192 # include <string.h> |
197 # include <stddef.h> | 193 # include <stddef.h> |
198 | 194 # include <errno.h> |
199 # ifdef __lucid | |
200 # include <sysent.h> | |
201 # endif | |
202 | 195 |
203 #endif | 196 #endif |
204 | 197 |
205 /* I don't understand this, but it's necessary to get some slots in struct exec | 198 /* I don't understand this, but it's necessary to get some slots in struct exec |
206 from /usr/include/sys/exec.h when running LCC in strict ANSI mode. We don't | 199 from /usr/include/sys/exec.h when running LCC in strict ANSI mode. We don't |
371 #ifdef emacs | 364 #ifdef emacs |
372 | 365 |
373 #include "lisp.h" | 366 #include "lisp.h" |
374 | 367 |
375 static void | 368 static void |
376 report_error (file, fd) | 369 report_error (const char *file, int fd) |
377 CONST char *file; | |
378 int fd; | |
379 { | 370 { |
380 if (fd) | 371 if (fd) |
381 close (fd); | 372 close (fd); |
382 report_file_error ("Cannot unexec", | 373 report_file_error ("Cannot unexec", |
383 Fcons (build_ext_string (file, FORMAT_FILENAME), Qnil)); | 374 Fcons (build_ext_string (file, Qfile_name), Qnil)); |
384 } | 375 } |
385 #endif /* emacs */ | 376 #endif /* emacs */ |
386 | 377 |
387 #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 | 378 #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 |
388 #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 | 379 #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 |
389 #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 | 380 #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 |
390 | 381 |
391 static void | 382 static void |
392 report_error_1 (fd, msg, a1, a2) | 383 report_error_1 (fd, msg, a1, a2) |
393 int fd; | 384 int fd; |
394 CONST char *msg; | 385 const char *msg; |
395 int a1, a2; | 386 int a1, a2; |
396 { | 387 { |
397 close (fd); | 388 close (fd); |
398 #ifdef emacs | 389 #ifdef emacs |
399 error (msg, a1, a2); | 390 error (msg, a1, a2); |
441 #endif | 432 #endif |
442 ) | 433 ) |
443 { | 434 { |
444 close (new); | 435 close (new); |
445 /* unlink (new_name); / * Failed, unlink new a.out */ | 436 /* unlink (new_name); / * Failed, unlink new a.out */ |
446 return -1; | 437 return -1; |
447 } | 438 } |
448 | 439 |
449 close (new); | 440 close (new); |
450 if (a_out >= 0) | 441 if (a_out >= 0) |
451 close (a_out); | 442 close (a_out); |
996 FILE *pfile; | 987 FILE *pfile; |
997 char *temp_ptr; | 988 char *temp_ptr; |
998 char c; | 989 char c; |
999 int mcount_address, mcount_offset, count; | 990 int mcount_address, mcount_offset, count; |
1000 extern char *_execname; | 991 extern char *_execname; |
1001 | 992 |
1002 | 993 |
1003 /* The use of _execname is incompatible with RISCiX 1.1 */ | 994 /* The use of _execname is incompatible with RISCiX 1.1 */ |
1004 sprintf (command, "nm %s | fgrep mcount", _execname); | 995 sprintf (command, "nm %s | fgrep mcount", _execname); |
1005 | 996 |
1006 if ( (pfile = popen(command, "r")) == NULL) | 997 if ( (pfile = popen(command, "r")) == NULL) |
1016 | 1007 |
1017 if ((count == 0) || pclose(pfile) != NULL) | 1008 if ((count == 0) || pclose(pfile) != NULL) |
1018 { | 1009 { |
1019 sprintf (errbuf, "Failed to execute the command '%s'\n", command); | 1010 sprintf (errbuf, "Failed to execute the command '%s'\n", command); |
1020 PERROR (errbuf); | 1011 PERROR (errbuf); |
1021 } | 1012 } |
1022 | 1013 |
1023 sscanf(address_text, "%x", &mcount_address); | 1014 sscanf(address_text, "%x", &mcount_address); |
1024 ptr = (char *) unexec_text_start; | 1015 ptr = (char *) unexec_text_start; |
1025 mcount_offset = (char *)mcount_address - ptr; | 1016 mcount_offset = (char *)mcount_address - ptr; |
1026 | 1017 |
1074 { | 1065 { |
1075 int i, nwrite, ret; | 1066 int i, nwrite, ret; |
1076 #if 0 | 1067 #if 0 |
1077 char buf[80]; | 1068 char buf[80]; |
1078 #endif | 1069 #endif |
1079 extern int errno; | |
1080 /* This is the normal amount to write at once. | 1070 /* This is the normal amount to write at once. |
1081 It is the size of block that NFS uses. */ | 1071 It is the size of block that NFS uses. */ |
1082 int writesize = 1 << 13; | 1072 int writesize = 1 << 13; |
1083 int pagesize = getpagesize (); | 1073 int pagesize = getpagesize (); |
1084 char zeros[1 << 13]; | 1074 char zeros[1 << 13]; |