delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/07/21/20:25:04

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <579167F3.4060700@gmx.de>
Date: Fri, 22 Jul 2016 02:25:23 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: LD from binutils 2.26 crashes when -ffunction-sections + -Wl,--gc-sections
is used but only under DOS
References: <e5d46af2-36fb-46af-af04-805ce2f8b6c3 AT googlegroups DOT com>
In-Reply-To: <e5d46af2-36fb-46af-af04-805ce2f8b6c3@googlegroups.com>
X-Provags-ID: V03:K0:4O/1cGaUOjoxF887d6XGI3ECsfsaYOuOzDr3PQnvjgFeHYhey4X
vF0nhOKVOQ6mNjYHHNifsD4jh63uClQcEw3JQNtoHsHgzOWiuVcZPY9BMgXE5Rk5g4B9lUq
jR4//WVQcM+BVm/MQwoYmxNucytX7o57rhbk8Buc4jBo/FDp78hkyHj89SBfWcRipX6svl9
MIXaz23es620FiV2Sz2KQ==
X-UI-Out-Filterresults: notjunk:1;V01:K0:WqU6N/ebZ8Y=:kDnr8tsv0dFl5J3sWQahIf
EPk0fiMKvR5CK6VKePtc4i2sht355N5J54w3/ct8Fmd68tZXwCPdMo3oYwH/Ng6rp/os8jISK
VaUD1rEf4vWP6bcaF7HGbXxu+hDwDJ43ClLvVPY/75yt06mGLLgPAbLq7cL0oDYgVVl6Cxdsv
3YPxnwSn3Mu4n/BN9O2ZX4j1X4EURrcZGQKXFrpOL42z55d5dOxOFhbCrKEGALg/VYNPH+z8A
J9CiZ4zTti1nf8g0dnjmGOm+/DwCoQ69UFL619zkNh8F+fLt4AZMdTVLH7KKzRvvK1ZSJWgR9
LvxT6W0VYgv1QKJTkZsQol3jWuJ+xnu1WG0CG1dkdWmSonUUMhlKH7hmSeR4BSVNqBLw4groy
ukwEe+ukBsAeQk/J8P4eOXcWA+TDsHqHjv+TjscBaCyudS74WKZsUO4mQWSZ6AahCU7yUA6ST
fR2dOuNVVp9U42qpKh6Pw/WZ9HMTGHrbtc07uqxVd+u2nFE30rywvQriNVcHHzjV9thVENTZ5
EWU0YMEQAM3VxU80S9yGF6Nf11qDeZjO9s5bN33nUJOuH3drdl+0PAai66L5UUoD/GoiCADew
EYT7w7ldtwjjsHeAZZZ7lnipLzBz6jP2XJ5tqx1prtu7nYJ2zSWR8elFj+Wa03qSfDm2DYzEQ
WeSsjGMflOnUirn2L8WuKR11KmDUTRoGqvqclGkLVozNec4RrOoCkLvubtBj5TGf3s5lM1iFk
0WVLCOrMGF2dcHDL7rPehLFYGPa/qzz8rgz0rGgB76VX0qXT28C59jpG+vA+3Ctn9kzzF8Iv0
k6/1wEB
Reply-To: djgpp AT delorie DOT com

Am 21.07.2016 19:55, schrieb RayeR (glaux AT centrum DOT cz) [via djgpp AT delorie DOT com]:
> I usually run DJGPP from WinXP on my main PC so it took me some time to hit this bug. I compiled one of my project under DOS where I use -ffunction-sections + -Wl,--gc-sections options in Makefile to reduce size of binary trashing unused code and after compiling all objects linker has crashed:
>
> gcc  -O2 -Wall -Wstrict-prototypes -ffunction-sections	-o SMB.EXE unisysio.o pc
> i.o ide.o smart.o isadev.o smbus.o smbdev.o spd.o smb.o -Wl,--gc-sections	
> Exiting due to signal SIGSEGV							
> Page fault at eip=0006154f, error=0004						
> eax=00000001 ebx=0026f3a8 ecx=0026f328 edx=00000000 esi=002cead0 edi=002ce038	
> ebp=000f875c esp=0017a670 program=e:/djgpp/bin/ld.exe				
> cs: sel=01a7  base=00a10000  limit=0045ffff					
> ds: sel=01af  base=00a10000  limit=0045ffff					
> es: sel=01af  base=00a10000  limit=0045ffff					
> fs: sel=018f  base=0005f180  limit=0000ffff					
> gs: sel=01bf  base=00000000  limit=0010ffff					
> ss: sel=01af  base=00a10000  limit=0045ffff					
> App stack: [0017a9f8..000fa9fc]  Exceptn stack: [000fa948..000f8a08]		
> 										
> Call frame traceback EIPs:							
>    0x0006154f									
> collect2.exe: error: ld returned 255 exit status				
> makefile:55: recipe for target 'SMB.EXE' failed 				
> make.exe: *** [SMB.EXE] Error 1
>
> and produced EXE was empty (zero Bytes). I tried on different PC and with/without XMS manager, DOS 6.22 and 7.1 but still crashes. Under Dosbox too. But when I run it under Win98SE or WinXP it compiles fine and EXE is valid. So I tried some older linker and found that LD.EXE from binutils 2.25 dated 1.6.2015 and some olders that I tried don't crash. So it was introduced recenlty in 2.26.
> I also tried to tune stack size in stub to 1M but didn't help. Any idea? Are there archived some older versions between 2.26 from 4.3.2016 and 2.25 from 1.6.2015?
>

1)  I would never claim that a DJGPP port of binutils is able to run on plain
     DOS at all.  I have never tried and I am surprised that some one has tried.

2)  I do not know how well COFF is still supported by the binutils maintainers.
     I do not know if there is still a COFF devoted maintainer at all and it is
     no secret that from time to time they break COFF support without note it
     until some of the last COFF users complains.
     I think there is no need to clarify that PECOFF has no real relation to the
     standard 32-bit COFF from the good old days and that if they support PECOFF
     for cygwin/mingw this does not imply in any way that they are still maintaining
     COFF.

2)  The last DJGPP specific change has been the implementation of 64K relocation
     support.  This has been introduced with the DJGPP port of binutils 2.22 in
     2012 and that implementation has never changed since them.  It has proven to
     work since 4 years and no other DJGPP specific changes have been implemented
     since them.

3)  As long as the compiled code does not exceed the 64k relocations per object
     file, this DJGPP specific change has absolute no influence in the object file
     generated.  If this support exists or not has no influence in the runtime
     behaviour of ld at all _as long as_ the relocation counter capacity is not
     exceed.

4)
 > But when I run it under Win98SE or WinXP it compiles fine and EXE is valid.
 > So I tried some older linker and found that LD.EXE from binutils 2.25 dated
 > 1.6.2015 and some olders that I tried don't crash. So it was introduced
 > recenlty in 2.26.

     Now we come to the crucial point and I will clarify, for the convenience
     of the audience, what you are claiming her:
     What you are discribing is that the DJGPP port of binutils 2.25 works on
     plain DOS because that was the absolute last port for which I have provided
     a version compiled with DJGPP 2.03.  All later ports are only availabe as
     compiled either with DJGPP 2.04 or with DJGPP 2.05.  And it is absolute
     __NO__ surprise that ports compiled with DJGPP 204 and/or DJGPP 2.05 work
     flawlessly in a NTVDM environment but may crash on plain DOS.  This is a
     very well known fact for the last 10 years probably.  Most of the developers
     that have made the great job to get DJGPP working on Win98 and later on
     Win2K and WinXP had probably no longer access to MSDOS machines so it was
     impossible for them to check if those improvements done had broken some old
     plain DOS support.  But who one cares about MSDOS or FreeDOS if he has the
     pleasure of NTVDM ?  Me certainly not; I do 100% of my DJGPP development on
     WinXP.

     The bottom line of all this is that no DJGPP port of binutils has ever been
     broken.  What we are experiencing here is a DJGPP 2.05 issue and nothing else.

5)  I will made available my private port of binutils that I use to compile the
     ports that I upload.  This port has the following features:
     - it honors the DISABLE_64K_RELOC_SUPPORT environment variable.  If set to
       "y" or "Y" it completely disables 64K relocation support.  If not defined
       or set to something different the it is ignored and 64K relocation support
       is enabled as in normal operation.
     - all binaries have been compiled with the -g2 -O0 flags and not striped at
       all.  Thus it may be possible to generate meanigfull stack traces.
     - due to this exceptional situation, it also provides all binaries compiled
       a second time using the old DJGPP 2.03.  They are located in the
          /gnu/binutils-2.26/djgpp/bin.203
       directory and can be used to replace the ones compiled with DJGPP 2.05.

    No, no one needs to ask me if I will provide all ports compiled with both
    versions of DJGPP because I will not do it.  DJGPP 2.03 is obsolete and it
    was difficult enough to get binutils 2.26 compiled with DJGPP 2.03 at all.


You can check your code with both versions of the linker and see what happens.
In the end it is your job to provide minimal sample code that makes it possible
to me to reproduce this issue so I can debug the library to see where to fix
the issue.  Fixing this may take weeks or months depending on my free time
and interest.

I will announce the new port release of binutils when it has been uploaded.


Regards,
Juan M. Guerrero

- Raw text -


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