comparison src/unexec.c @ 91702:b7a5a89054dc

* configure.in (LIBX11_MACHINE, HAVE_XFREE386): Remove code dealing with obsolete variables. * fakemail.c (MAIL_PROGRAM_NAME): Remove unused conditional. (main): Replace MAIL_PROGRAM_NAME with its value. * src/Makefile.in: * src/emacs.c: * src/gmalloc.c: * src/keyboard.c: * src/lisp.h: * src/m/ibm370aix.h: * src/process.c: * src/regex.c: * src/s/hpux.h: * src/sysdep.c: * src/sysselect.h: * src/systty.h: * src/unexec.c: * src/w32term.c: * src/xsmfns.c: * src/xterm.c: Remove code that deals with obsolete variables. * s/msdos.h (DONT_NEED_ENVIRON): Don't define. * ecrt0.c: Replace the DONT_NEED_ENVIRON test with MSDOS test, nothing else needs it anymore.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 09 Feb 2008 18:03:10 +0000
parents 0a928dba3639
children 8971ddf55736
comparison
equal deleted inserted replaced
91701:8fac5ad6ff83 91702:b7a5a89054dc
131 * A_TEXT_SEEK(HDR) 131 * A_TEXT_SEEK(HDR)
132 132
133 If defined, this macro specifies the number of bytes to seek into the 133 If defined, this macro specifies the number of bytes to seek into the
134 a.out file before starting to write the text segment. 134 a.out file before starting to write the text segment.
135 135
136 * EXEC_MAGIC
137
138 For machines using COFF, this macro, if defined, is a value stored
139 into the magic number field of the output file.
140
141 * ADJUST_EXEC_HEADER 136 * ADJUST_EXEC_HEADER
142 137
143 This macro can be used to generate statements to adjust or 138 This macro can be used to generate statements to adjust or
144 initialize nonstandard fields in the file header 139 initialize nonstandard fields in the file header
145 140
155 */ 150 */
156 151
157 #ifndef emacs 152 #ifndef emacs
158 #define PERROR(arg) perror (arg); return -1 153 #define PERROR(arg) perror (arg); return -1
159 #else 154 #else
160 #define IN_UNEXEC
161 #include <config.h> 155 #include <config.h>
162 #define PERROR(file) report_error (file, new) 156 #define PERROR(file) report_error (file, new)
163 #endif 157 #endif
164 158
165 #ifndef CANNOT_DUMP /* all rest of file! */ 159 #ifndef CANNOT_DUMP /* all rest of file! */
254 #endif 248 #endif
255 #endif /* HPUX */ 249 #endif /* HPUX */
256 250
257 #define SYMS_START ((long) N_SYMOFF (ohdr)) 251 #define SYMS_START ((long) N_SYMOFF (ohdr))
258 252
259 /* Some machines override the structure name for an a.out header. */
260 #ifndef EXEC_HDR_TYPE
261 #define EXEC_HDR_TYPE struct exec
262 #endif
263
264 #ifdef HPUX 253 #ifdef HPUX
265 #ifdef HP9000S200_ID 254 #ifdef HP9000S200_ID
266 #define MY_ID HP9000S200_ID 255 #define MY_ID HP9000S200_ID
267 #else 256 #else
268 #include <model.h> 257 #include <model.h>
270 #endif /* no HP9000S200_ID */ 259 #endif /* no HP9000S200_ID */
271 static MAGIC OLDMAGIC = {MY_ID, SHARE_MAGIC}; 260 static MAGIC OLDMAGIC = {MY_ID, SHARE_MAGIC};
272 static MAGIC NEWMAGIC = {MY_ID, DEMAND_MAGIC}; 261 static MAGIC NEWMAGIC = {MY_ID, DEMAND_MAGIC};
273 #define N_TXTOFF(x) TEXT_OFFSET(x) 262 #define N_TXTOFF(x) TEXT_OFFSET(x)
274 #define N_SYMOFF(x) LESYM_OFFSET(x) 263 #define N_SYMOFF(x) LESYM_OFFSET(x)
275 static EXEC_HDR_TYPE hdr, ohdr; 264 static struct exec hdr, ohdr;
276 265
277 #else /* not HPUX */ 266 #else /* not HPUX */
278 267
279 #if defined (USG) && !defined (IBMAIX) && !defined (IRIS) && !defined (GNU_LINUX) 268 #if defined (USG) && !defined (IRIS) && !defined (GNU_LINUX)
280 static struct bhdr hdr, ohdr; 269 static struct bhdr hdr, ohdr;
281 #define a_magic fmagic 270 #define a_magic fmagic
282 #define a_text tsize 271 #define a_text tsize
283 #define a_data dsize 272 #define a_data dsize
284 #define a_bss bsize 273 #define a_bss bsize
288 #define a_entry entry 277 #define a_entry entry
289 #define N_BADMAG(x) \ 278 #define N_BADMAG(x) \
290 (((x).fmagic)!=OMAGIC && ((x).fmagic)!=NMAGIC &&\ 279 (((x).fmagic)!=OMAGIC && ((x).fmagic)!=NMAGIC &&\
291 ((x).fmagic)!=FMAGIC && ((x).fmagic)!=IMAGIC) 280 ((x).fmagic)!=FMAGIC && ((x).fmagic)!=IMAGIC)
292 #define NEWMAGIC FMAGIC 281 #define NEWMAGIC FMAGIC
293 #else /* IRIS or IBMAIX or not USG */ 282 #else /* IRIS or not USG */
294 static EXEC_HDR_TYPE hdr, ohdr; 283 static struct exec hdr, ohdr;
295 #define NEWMAGIC ZMAGIC 284 #define NEWMAGIC ZMAGIC
296 #endif /* IRIS or IBMAIX not USG */ 285 #endif /* IRIS or not USG */
297 #endif /* not HPUX */ 286 #endif /* not HPUX */
298 287
299 static int unexec_text_start; 288 static int unexec_text_start;
300 static int unexec_data_start; 289 static int unexec_data_start;
301 290
502 bias = bss_start - (f_ohdr.data_start + f_dhdr.s_size); 491 bias = bss_start - (f_ohdr.data_start + f_dhdr.s_size);
503 492
504 #endif 493 #endif
505 494
506 f_hdr.f_flags |= (F_RELFLG | F_EXEC); 495 f_hdr.f_flags |= (F_RELFLG | F_EXEC);
507 #ifdef TPIX
508 f_hdr.f_nscns = 3;
509 #endif
510 #ifdef EXEC_MAGIC
511 f_ohdr.magic = EXEC_MAGIC;
512 #endif
513 #ifndef NO_REMAP 496 #ifndef NO_REMAP
514 f_ohdr.text_start = (long) start_of_text (); 497 f_ohdr.text_start = (long) start_of_text ();
515 f_ohdr.tsize = data_start - f_ohdr.text_start; 498 f_ohdr.tsize = data_start - f_ohdr.text_start;
516 f_ohdr.data_start = data_start; 499 f_ohdr.data_start = data_start;
517 #endif /* NO_REMAP */ 500 #endif /* NO_REMAP */
518 f_ohdr.dsize = bss_start - f_ohdr.data_start; 501 f_ohdr.dsize = bss_start - f_ohdr.data_start;
519 f_ohdr.bsize = bss_end - bss_start; 502 f_ohdr.bsize = bss_end - bss_start;
520 #ifndef KEEP_OLD_TEXT_SCNPTR
521 /* On some machines, the old values are right. 503 /* On some machines, the old values are right.
522 ??? Maybe on all machines with NO_REMAP. */ 504 ??? Maybe on all machines with NO_REMAP. */
523 f_thdr.s_size = f_ohdr.tsize; 505 f_thdr.s_size = f_ohdr.tsize;
524 f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr); 506 f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr);
525 f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr)); 507 f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr));
526 #endif /* KEEP_OLD_TEXT_SCNPTR */
527 #ifdef ADJUST_TEXT_SCNHDR_SIZE 508 #ifdef ADJUST_TEXT_SCNHDR_SIZE
528 /* On some machines, `text size' includes all headers. */ 509 /* On some machines, `text size' includes all headers. */
529 f_thdr.s_size -= f_thdr.s_scnptr; 510 f_thdr.s_size -= f_thdr.s_scnptr;
530 #endif /* ADJUST_TEST_SCNHDR_SIZE */ 511 #endif /* ADJUST_TEST_SCNHDR_SIZE */
531 lnnoptr = f_thdr.s_lnnoptr; 512 lnnoptr = f_thdr.s_lnnoptr;
533 /* Some systems require special alignment 514 /* Some systems require special alignment
534 of the sections in the file itself. */ 515 of the sections in the file itself. */
535 f_thdr.s_scnptr 516 f_thdr.s_scnptr
536 = (f_thdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT; 517 = (f_thdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT;
537 #endif /* SECTION_ALIGNMENT */ 518 #endif /* SECTION_ALIGNMENT */
538 #ifdef TPIX
539 f_thdr.s_scnptr = 0xd0;
540 #endif
541 text_scnptr = f_thdr.s_scnptr; 519 text_scnptr = f_thdr.s_scnptr;
542 #ifdef ADJUST_TEXTBASE
543 text_scnptr = sizeof (f_hdr) + sizeof (f_ohdr) + (f_hdr.f_nscns) * (sizeof (f_thdr));
544 #endif
545 #ifndef KEEP_OLD_PADDR
546 f_dhdr.s_paddr = f_ohdr.data_start; 520 f_dhdr.s_paddr = f_ohdr.data_start;
547 #endif /* KEEP_OLD_PADDR */
548 f_dhdr.s_vaddr = f_ohdr.data_start; 521 f_dhdr.s_vaddr = f_ohdr.data_start;
549 f_dhdr.s_size = f_ohdr.dsize; 522 f_dhdr.s_size = f_ohdr.dsize;
550 f_dhdr.s_scnptr = f_thdr.s_scnptr + f_thdr.s_size; 523 f_dhdr.s_scnptr = f_thdr.s_scnptr + f_thdr.s_size;
551 #ifdef SECTION_ALIGNMENT 524 #ifdef SECTION_ALIGNMENT
552 /* Some systems require special alignment 525 /* Some systems require special alignment
559 of the data section only. */ 532 of the data section only. */
560 f_dhdr.s_scnptr 533 f_dhdr.s_scnptr
561 = (f_dhdr.s_scnptr + DATA_SECTION_ALIGNMENT) & ~DATA_SECTION_ALIGNMENT; 534 = (f_dhdr.s_scnptr + DATA_SECTION_ALIGNMENT) & ~DATA_SECTION_ALIGNMENT;
562 #endif /* DATA_SECTION_ALIGNMENT */ 535 #endif /* DATA_SECTION_ALIGNMENT */
563 data_scnptr = f_dhdr.s_scnptr; 536 data_scnptr = f_dhdr.s_scnptr;
564 #ifndef KEEP_OLD_PADDR
565 f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize; 537 f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize;
566 #endif /* KEEP_OLD_PADDR */
567 f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize; 538 f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize;
568 f_bhdr.s_size = f_ohdr.bsize; 539 f_bhdr.s_size = f_ohdr.bsize;
569 f_bhdr.s_scnptr = 0L; 540 f_bhdr.s_scnptr = 0L;
570 #ifndef USG_SHARED_LIBRARIES 541 #ifndef USG_SHARED_LIBRARIES
571 bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start; 542 bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start;
872 #endif 843 #endif
873 #endif 844 #endif
874 845
875 lseek (new, (long) text_scnptr, 0); 846 lseek (new, (long) text_scnptr, 0);
876 ptr = (char *) f_ohdr.text_start; 847 ptr = (char *) f_ohdr.text_start;
877 #ifdef HEADER_INCL_IN_TEXT
878 /* For Gould UTX/32, text starts after headers */
879 ptr = (char *) (ptr + text_scnptr);
880 #endif /* HEADER_INCL_IN_TEXT */
881 end = ptr + f_ohdr.tsize; 848 end = ptr + f_ohdr.tsize;
882 write_segment (new, ptr, end); 849 write_segment (new, ptr, end);
883 850
884 lseek (new, (long) data_scnptr, 0); 851 lseek (new, (long) data_scnptr, 0);
885 ptr = (char *) f_ohdr.data_start; 852 ptr = (char *) f_ohdr.data_start;