Mercurial > hg > xemacs-beta
comparison src/unexec.c @ 438:84b14dcb0985 r21-2-27
Import from CVS: tag r21-2-27
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:32:25 +0200 |
parents | 3ecd8885ac67 |
children | 8de8e3f6228a |
comparison
equal
deleted
inserted
replaced
437:e2a4e8b94b82 | 438:84b14dcb0985 |
---|---|
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 |
441 #endif | 434 #endif |
442 ) | 435 ) |
443 { | 436 { |
444 close (new); | 437 close (new); |
445 /* unlink (new_name); / * Failed, unlink new a.out */ | 438 /* unlink (new_name); / * Failed, unlink new a.out */ |
446 return -1; | 439 return -1; |
447 } | 440 } |
448 | 441 |
449 close (new); | 442 close (new); |
450 if (a_out >= 0) | 443 if (a_out >= 0) |
451 close (a_out); | 444 close (a_out); |
996 FILE *pfile; | 989 FILE *pfile; |
997 char *temp_ptr; | 990 char *temp_ptr; |
998 char c; | 991 char c; |
999 int mcount_address, mcount_offset, count; | 992 int mcount_address, mcount_offset, count; |
1000 extern char *_execname; | 993 extern char *_execname; |
1001 | 994 |
1002 | 995 |
1003 /* The use of _execname is incompatible with RISCiX 1.1 */ | 996 /* The use of _execname is incompatible with RISCiX 1.1 */ |
1004 sprintf (command, "nm %s | fgrep mcount", _execname); | 997 sprintf (command, "nm %s | fgrep mcount", _execname); |
1005 | 998 |
1006 if ( (pfile = popen(command, "r")) == NULL) | 999 if ( (pfile = popen(command, "r")) == NULL) |
1016 | 1009 |
1017 if ((count == 0) || pclose(pfile) != NULL) | 1010 if ((count == 0) || pclose(pfile) != NULL) |
1018 { | 1011 { |
1019 sprintf (errbuf, "Failed to execute the command '%s'\n", command); | 1012 sprintf (errbuf, "Failed to execute the command '%s'\n", command); |
1020 PERROR (errbuf); | 1013 PERROR (errbuf); |
1021 } | 1014 } |
1022 | 1015 |
1023 sscanf(address_text, "%x", &mcount_address); | 1016 sscanf(address_text, "%x", &mcount_address); |
1024 ptr = (char *) unexec_text_start; | 1017 ptr = (char *) unexec_text_start; |
1025 mcount_offset = (char *)mcount_address - ptr; | 1018 mcount_offset = (char *)mcount_address - ptr; |
1026 | 1019 |
1074 { | 1067 { |
1075 int i, nwrite, ret; | 1068 int i, nwrite, ret; |
1076 #if 0 | 1069 #if 0 |
1077 char buf[80]; | 1070 char buf[80]; |
1078 #endif | 1071 #endif |
1079 extern int errno; | |
1080 /* This is the normal amount to write at once. | 1072 /* This is the normal amount to write at once. |
1081 It is the size of block that NFS uses. */ | 1073 It is the size of block that NFS uses. */ |
1082 int writesize = 1 << 13; | 1074 int writesize = 1 << 13; |
1083 int pagesize = getpagesize (); | 1075 int pagesize = getpagesize (); |
1084 char zeros[1 << 13]; | 1076 char zeros[1 << 13]; |