delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/28/08:02:02

Date: Sun, 28 Jun 1998 15:01:44 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Ian Miller <itmiller AT dera DOT gov DOT uk>, djgpp AT delorie DOT com
Subject: Re: ...and now problem when trying to recompile libm.a !
In-Reply-To: <Pine.SUN.3.91.980625134355.27632A-100000@is>
Message-ID: <Pine.SUN.3.91.980628145611.9146A-100000@is>
MIME-Version: 1.0

On 27 Jun 1998, Ian Miller wrote:

> After a little effort I realised that
> the dump process was expecting temacs to be an *unstubbed* coff
> file. Under the port of gcc 2.8x, it isn't. exe2coff sorts things out. The
> patch to emacs-20.2/msdos/sed1v2.inp below sorts things out for me.

Thanks a lot for an accurate diagnostics.

However, I think that sed1v2.inp is not the best place to take care of 
this problem, since `dump-emacs' can be invoked from something else than 
temacs.exe (this is one way of making all your customizations permanently 
wired into the binary), although this is seldom used.  So I think a 
better way wold be to make Emacs support coff-go32-exe executables.

Please try the following patch (after reverting sed1v2.inp to its 
previous shape) and tell me if it works for you.

*** src/unexec.c~0	Fri Jul 19 22:46:02 1996
--- src/unexec.c	Sun Jun 28 13:59:42 1998
*************** long lnnoptr;			/* Pointer to line-numbe
*** 245,250 ****
--- 245,252 ----
  static long text_scnptr;
  static long data_scnptr;
  
+ static long coff_offset;
+ 
  #else /* not COFF */
  
  #ifdef HPUX
*************** make_hdr (new, a_out, data_start, bss_st
*** 476,484 ****
--- 478,509 ----
      }
  
  #ifdef COFF
+   coff_offset = 0L;		/* stays zero, except in DJGPP */
+ 
    /* Salvage as much info from the existing file as possible */
    if (a_out >= 0)
      {
+ #ifdef MSDOS
+ #if __DJGPP__ > 1
+       /* Support the coff-go32-exe format with a prepended stub, since
+ 	 this is what GCC 2.8.0 and later generates by default in DJGPP.  */
+       unsigned short mz_header[3];
+ 
+       if (read (a_out, &mz_header, sizeof (mz_header)) != sizeof (mz_header))
+ 	{
+ 	  PERROR (a_name);
+ 	}
+       if (mz_header[0] == 0x5a4d || mz_header[0] == 0x4d5a) /* "MZ" or "ZM" */
+ 	{
+ 	  coff_offset = (long)mz_header[2] * 512L;
+ 	  if (mz_header[1])
+ 	    coff_offset += (long)mz_header[1] - 512L;
+ 	  lseek (a_out, coff_offset, 0);
+ 	}
+       else
+ 	lseek (a_out, 0L, 0);
+ #endif /* __DJGPP__ > 1 */
+ #endif /* MSDOS */
        if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr))
  	{
  	  PERROR (a_name);
*************** make_hdr (new, a_out, data_start, bss_st
*** 493,499 ****
  	  block_copy_start += sizeof (f_ohdr);
  	}
        /* Loop through section headers, copying them in */
!       lseek (a_out, sizeof (f_hdr) + f_hdr.f_opthdr, 0);
        for (scns = f_hdr.f_nscns; scns > 0; scns--) {
  	if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
  	  {
--- 518,524 ----
  	  block_copy_start += sizeof (f_ohdr);
  	}
        /* Loop through section headers, copying them in */
!       lseek (a_out, coff_offset + sizeof (f_hdr) + f_hdr.f_opthdr, 0);
        for (scns = f_hdr.f_nscns; scns > 0; scns--) {
  	if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp))
  	  {
*************** copy_sym (new, a_out, a_name, new_name)
*** 1113,1122 ****
  
  #ifdef COFF
    if (lnnoptr)			/* if there is line number info */
!     lseek (a_out, lnnoptr, 0);	/* start copying from there */
    else
! #endif /* COFF */
!     lseek (a_out, SYMS_START, 0);	/* Position a.out to symtab. */
  
    while ((n = read (a_out, page, sizeof page)) > 0)
      {
--- 1138,1149 ----
  
  #ifdef COFF
    if (lnnoptr)			/* if there is line number info */
!     lseek (a_out, coff_offset + lnnoptr, 0);	/* start copying from there */
    else
!     lseek (a_out, coff_offset + SYMS_START, 0);	/* Position a.out to symtab. */
! #else  /* not COFF */
!   lseek (a_out, SYMS_START, 0);	/* Position a.out to symtab. */
! #endif /* not COFF */
  
    while ((n = read (a_out, page, sizeof page)) > 0)
      {

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019