aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-29 22:54:28 +0000
committerRichard M. Stallman1998-06-29 22:54:28 +0000
commitc8b14b5fbe3791de80b8086d4889456a9a62cde9 (patch)
treeb0e01d29805004111c568939a4464576a88fbd5f /src
parentfedfa856e96e4d2bece8370822568315b7d20f69 (diff)
downloademacs-c8b14b5fbe3791de80b8086d4889456a9a62cde9.tar.gz
emacs-c8b14b5fbe3791de80b8086d4889456a9a62cde9.zip
[COFF]: New variable coff_offset.
(make_hdr) [MSDOS]: If a_name is a coff-go32-exe executable with a prepended stub, compute coff_offset. (make_hdr, copy_sym) [COFF]: Use coff_offset when seeking into temacs.
Diffstat (limited to 'src')
-rw-r--r--src/unexec.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/unexec.c b/src/unexec.c
index f7ff9ca6b02..eebb8911caf 100644
--- a/src/unexec.c
+++ b/src/unexec.c
@@ -245,6 +245,8 @@ long lnnoptr; /* Pointer to line-number info within file */
245static long text_scnptr; 245static long text_scnptr;
246static long data_scnptr; 246static long data_scnptr;
247 247
248static long coff_offset;
249
248#else /* not COFF */ 250#else /* not COFF */
249 251
250#ifdef HPUX 252#ifdef HPUX
@@ -476,9 +478,32 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
476 } 478 }
477 479
478#ifdef COFF 480#ifdef COFF
481 coff_offset = 0L; /* stays zero, except in DJGPP */
482
479 /* Salvage as much info from the existing file as possible */ 483 /* Salvage as much info from the existing file as possible */
480 if (a_out >= 0) 484 if (a_out >= 0)
481 { 485 {
486#ifdef MSDOS
487#if __DJGPP__ > 1
488 /* Support the coff-go32-exe format with a prepended stub, since
489 this is what GCC 2.8.0 and later generates by default in DJGPP. */
490 unsigned short mz_header[3];
491
492 if (read (a_out, &mz_header, sizeof (mz_header)) != sizeof (mz_header))
493 {
494 PERROR (a_name);
495 }
496 if (mz_header[0] == 0x5a4d || mz_header[0] == 0x4d5a) /* "MZ" or "ZM" */
497 {
498 coff_offset = (long)mz_header[2] * 512L;
499 if (mz_header[1])
500 coff_offset += (long)mz_header[1] - 512L;
501 lseek (a_out, coff_offset, 0);
502 }
503 else
504 lseek (a_out, 0L, 0);
505#endif /* __DJGPP__ > 1 */
506#endif /* MSDOS */
482 if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr)) 507 if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
483 { 508 {
484 PERROR (a_name); 509 PERROR (a_name);
@@ -493,7 +518,7 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name)
493 block_copy_start += sizeof (f_ohdr); 518 block_copy_start += sizeof (f_ohdr);
494 } 519 }
495 /* Loop through section headers, copying them in */ 520 /* Loop through section headers, copying them in */
496 lseek (a_out, sizeof (f_hdr) + f_hdr.f_opthdr, 0); 521 lseek (a_out, coff_offset + sizeof (f_hdr) + f_hdr.f_opthdr, 0);
497 for (scns = f_hdr.f_nscns; scns > 0; scns--) { 522 for (scns = f_hdr.f_nscns; scns > 0; scns--) {
498 if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp)) 523 if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
499 { 524 {
@@ -1113,10 +1138,12 @@ copy_sym (new, a_out, a_name, new_name)
1113 1138
1114#ifdef COFF 1139#ifdef COFF
1115 if (lnnoptr) /* if there is line number info */ 1140 if (lnnoptr) /* if there is line number info */
1116 lseek (a_out, lnnoptr, 0); /* start copying from there */ 1141 lseek (a_out, coff_offset + lnnoptr, 0); /* start copying from there */
1117 else 1142 else
1118#endif /* COFF */ 1143 lseek (a_out, coff_offset + SYMS_START, 0); /* Position a.out to symtab. */
1119 lseek (a_out, SYMS_START, 0); /* Position a.out to symtab. */ 1144#else /* not COFF */
1145 lseek (a_out, SYMS_START, 0); /* Position a.out to symtab. */
1146#endif /* not COFF */
1120 1147
1121 while ((n = read (a_out, page, sizeof page)) > 0) 1148 while ((n = read (a_out, page, sizeof page)) > 0)
1122 { 1149 {