Web lists-archives.com

Re: Defective "portable executables" distributed/created by Cygwin




On 10/05/2018 21:29, Marco Atzeri wrote:
On 5/10/2018 8:30 PM, Stefan Kanthak wrote:
Hi @ll,

the "portable executables" distributed by Cygwin (and of course those
created with Cygwin's GCC toolchain too) have INVALID/ILLEGAL headers:

0. Microsoft's DUMPBIN.EXE alias LINK.EXE /DUMP aborts with
    "access violation" (see below) on almost all Cygwin binaries!

A program should never fail in such way. It seems the program is NOT
validating properly its input and it is probably expecting the
organization of the data as used by Microsoft Visual Studio 2010.
As it fails probably you can not fully trust its output
for program built from other compilers.


1. they use INVALID/ILLEGAL section names like "/4" or "/14", upon
    which Microsoft's DUMPBIN.EXE alias LINK.EXE /DUMP stops enumerating
    the section headers (see below)!

It seems Cygwin tools disagree with such interpretation

This deviation is deliberate, and is discussed in the ld manpage for the option which controls it:

       --enable-long-section-names
       --disable-long-section-names
The PE variants of the COFF object format add an extension that
permits the use of section names longer than eight characters, the
normal limit for COFF.  By default, these names are only allowed in
object files, as fully-linked executable images do not carry the
COFF string table required to support the longer names.  As a GNU
extension, it is possible to allow their use in executable images
as well, or to (probably pointlessly!)  disallow it in object
files, by using these two options.  Executable images generated
with these long section names are slightly non-standard, carrying
as they do a string table, and may generate confusing output when
examined with non-GNU PE-aware tools, such as file viewers and
dumpers.  However, GDB relies on the use of PE long section names
to find Dwarf-2 debug information sections in an executable image
at runtime, and so if neither option is specified on the command-
line, ld will enable long section names, overriding the default and
technically correct behaviour, when it finds the presence of debug
information while linking an executable image and not stripping
symbols.  [This option is valid for all PE targeted ports of the
linker]

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