BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Peter Rehley
Hi,

After compiling a snapshot, I tried to strip the cygwin1.dll using  
the binutils strip command.  After I did this I started seeing this  
windows dialog box appear:

"ls.exe - Bad Image

The application or DLL F:\cygwin\home\peter\tmp\cygwin1.dll is not a  
valid Windows image.  Please check this against your installation  
diskette."

I first tried this on cygwin 1.5.18 using binutils 20050610.  I then  
updated my cygwin to the latest snapshot and tried again, and I got  
the same message.  I then tried rebuilding binutils, just to make  
sure it wasn't a binutils build issue, and received the same error  
message when I used this recompiled strip.

Let me know is you need additional information...cycheck output for  
snapshot is attached.
Peter


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

cygcheck_20051103.out (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Christopher Faylor-2
On Thu, Nov 03, 2005 at 04:17:57PM -0800, Peter Rehley wrote:
>After compiling a snapshot, I tried to strip the cygwin1.dll using  
>the binutils strip command.  After I did this I started seeing this  
>windows dialog box appear:
>
>"ls.exe - Bad Image

This is not a bug.  You can't strip the DLL as it is already stripped
as much as possible.  The debugging information is now in a different
file.

http://cygwin.com/ml/cygwin/2005-08/msg00277.html

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Eric Blake (cygwin)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Christopher Faylor on 11/3/2005 6:51 PM:
>
> This is not a bug.  You can't strip the DLL as it is already stripped
> as much as possible.  The debugging information is now in a different
> file.

Then I would argue that strip should be a no-op and leave the size of
cygwin1.dll unchanged, rather than stripping out whatever was essential
that made the dll invalid.  It is not a bug in your philosophy of shipping
cygwin1.dll already stripped, but it IS annoying that binutils can't
recognize that fact and instead corrupts the file.

- --
Life is short - so eat dessert first!

Eric Blake             [hidden email]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDa1dx84KuGfSFAYARAjhwAJ9E/t/GGqkiAimgevMZ7kM6UbpYygCfZhO6
wvBCws9jw2VVHEvhrAQe7R0=
=HIdo
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Corinna Vinschen-2
On Nov  4 05:43, Eric Blake wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> According to Christopher Faylor on 11/3/2005 6:51 PM:
> >
> > This is not a bug.  You can't strip the DLL as it is already stripped
> > as much as possible.  The debugging information is now in a different
> > file.
>
> Then I would argue that strip should be a no-op and leave the size of
> cygwin1.dll unchanged, rather than stripping out whatever was essential
> that made the dll invalid.  It is not a bug in your philosophy of shipping
> cygwin1.dll already stripped, but it IS annoying that binutils can't
> recognize that fact and instead corrupts the file.

The problem is that there's one section in the file, .gnu_debuglink,
which is defined as a debugging section.  strip's job is to remove all
debug sections.  This is usually a simple job to do since the debug
sections are typically at the end of the file anyway.  Not so the
.gnu_debuglink section.  By stripping this out, strip generates an
invalid PE/COFF file since it leaves an undefined memory hole in the
address space of the file, which is a no-no with the somewhat overly
simple Windows runtime loader.

It's an unlucky case.  You could argue that strip should know better
than to remove debug sections from the middle of a PE/COFF file but
OTOH the Cygwin DLL is a very special case.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Eric Blake (cygwin)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Corinna Vinschen on 11/4/2005 6:11 AM:
>
> The problem is that there's one section in the file, .gnu_debuglink,
> which is defined as a debugging section.  strip's job is to remove all
> debug sections.  This is usually a simple job to do since the debug
> sections are typically at the end of the file anyway.  Not so the
> .gnu_debuglink section.  By stripping this out, strip generates an
> invalid PE/COFF file since it leaves an undefined memory hole in the
> address space of the file, which is a no-no with the somewhat overly
> simple Windows runtime loader.

Wow.  Learn something every day.  No wonder ELF is so much more popular in
the open source community.

>
> It's an unlucky case.  You could argue that strip should know better
> than to remove debug sections from the middle of a PE/COFF file but
> OTOH the Cygwin DLL is a very special case.

So the cygwin DLL is likely to be the only PE/COFF dll that strip ever
encounters with a section marked as debug in the middle of a file?  If it
is ever expected that other DLLs will have the same property, then yes,
strip should be taught to not strip intermediate debug sections; but if it
is just cygwin1.dll, I can live with the rule of thumb of "don't do it if
it hurts".

- --
Life is short - so eat dessert first!

Eric Blake             [hidden email]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDa2XM84KuGfSFAYARAv1EAJ4zk9aROsY6OxB4q6UdLwbAt1NJpwCgxNIY
fKtZBAbvuCsGIJ1kBLX87f4=
=Xxql
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Corinna Vinschen-2
On Nov  4 06:44, Eric Blake wrote:

> According to Corinna Vinschen on 11/4/2005 6:11 AM:
> > The problem is that there's one section in the file, .gnu_debuglink,
> > which is defined as a debugging section.  strip's job is to remove all
> > debug sections.  This is usually a simple job to do since the debug
> > sections are typically at the end of the file anyway.  Not so the
> > .gnu_debuglink section.  By stripping this out, strip generates an
> > invalid PE/COFF file since it leaves an undefined memory hole in the
> > address space of the file, which is a no-no with the somewhat overly
> > simple Windows runtime loader.
>
> Wow.  Learn something every day.  No wonder ELF is so much more popular in
> the open source community.
>
> > It's an unlucky case.  You could argue that strip should know better
> > than to remove debug sections from the middle of a PE/COFF file but
> > OTOH the Cygwin DLL is a very special case.
>
> So the cygwin DLL is likely to be the only PE/COFF dll that strip ever
> encounters with a section marked as debug in the middle of a file?  If it
> is ever expected that other DLLs will have the same property, then yes,
> strip should be taught to not strip intermediate debug sections; but if it
> is just cygwin1.dll, I can live with the rule of thumb of "don't do it if
> it hurts".

It's very likely that the Cygwin DLL is the only one (*) having this
special layout.  The debug sections are usually at the end of the file
since that's how the linker description files look like.  Cygwin uses
its own linker description file, because it requires that the last
section in the file is the .cygheap section, which is designed as a
potentially growing section.

I agree that it would be nice if strip would not strip debug sections
from the middle of the file, but it doesn't look like there would be any
pressing need for that.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply | Threaded
Open this post in threaded view
|

Re: BUG: Binutils strip corrupts dll files when using cygwin 1.5.18 and latest snapshot (20051103)

Christopher Faylor-2
In reply to this post by Eric Blake (cygwin)
On Fri, Nov 04, 2005 at 06:44:44AM -0700, Eric Blake wrote:

>According to Corinna Vinschen on 11/4/2005 6:11 AM:
>>The problem is that there's one section in the file, .gnu_debuglink,
>>which is defined as a debugging section.  strip's job is to remove all
>>debug sections.  This is usually a simple job to do since the debug
>>sections are typically at the end of the file anyway.  Not so the
>>.gnu_debuglink section.  By stripping this out, strip generates an
>>invalid PE/COFF file since it leaves an undefined memory hole in the
>>address space of the file, which is a no-no with the somewhat overly
>>simple Windows runtime loader.
>
>Wow.  Learn something every day.  No wonder ELF is so much more popular
>in the open source community.

Yeah, we tried hard to convince the open source community to use PE/COFF
and to start adopting the use of extensions like '.exe', and '.dll' but
you know how they are.

>>It's an unlucky case.  You could argue that strip should know better
>>than to remove debug sections from the middle of a PE/COFF file but
>>OTOH the Cygwin DLL is a very special case.
>
>So the cygwin DLL is likely to be the only PE/COFF dll that strip ever
>encounters with a section marked as debug in the middle of a file?

Yes.  Let me quote from the link that I provided since it seems like you
haven't read it:

>cgf wrote:
>>The splitting of the debug information into a new file is something that
>>I've wanted to do for a long time but problems with the standard
>>binutils way of accomplishing this task had proven to be daunting for PE
>>format executables.  I took some time today to try to understand what
>>was going wrong and wrote a script to fix up the dll so that information
>>about cygwin1.dbg was included in cygwin1.dll in a way that does not
>>cause cygwin1.dll to be an invalid binary -- which was the problem
>>before.
>>
>>Eventually, I will fix binutils so that this workaround is no longer
>>necessary and, then, it will be possible to create separate debug files
>>for any binary, without the need for my fixup.

So, to clarify, I was wrong to say that it wasn't a bug before.  It is
at least arguably a bug that binutils creates a bad dll if you strip
cygwin1.dll.  However, if you read the above it should be pretty clear
that this is a problem that is understood and that notes of concern
about the behavior are not required.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/