MingW-related setup.exe crash w/ DEP enabled

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Mar 17 16:09:00 GMT 2010

On Mar 17 16:45, Corinna Vinschen wrote:
> On Mar 17 11:18, Christopher Faylor wrote:
> > On Wed, Mar 17, 2010 at 04:09:12PM +0100, Corinna Vinschen wrote:
> > >Strange enough, the same does not occur with the net setup built by cgf
> > >for some reason.  Chris, do you use an older MingW by any chance?
> > 
> > Yes.  I cross build setup and, while I periodically update my build
> > environment for Cygwin, I haven't updated it for MinGW for many years.
> Ok, so you better stick to it for the time being :|

Given the weird error message of upx, I'm now wondering if one or both
of the .tls and .CRT sections have to be executable.  Objdump -h shows

Idx Name        Size      VMA       LMA       File off  Algn
  4 .CRT        00000018, 005b5000, 005b5000  0019a600  2**2
                CONTENTS, ALLOC, LOAD, DATA
  5 .tls        00000020, 005b6000, 005b6000  0019a800  2**2
                CONTENTS, ALLOC, LOAD, DATA

*If* these sections contain any executable code, then the DEP SEGV
is an expected result!

See http://technet.microsoft.com/en-us/library/cc738483%28WS.10%29.aspx

  A small number of executables and libraries may contain executable
  code in a data section of the image file. In some cases, applications
  may place small segments of code (commonly referred to as thunks) in
  the data sections. However, DEP will mark sections of the image file
  loaded in memory as non-executable unless the section has the
  executable attribute applied.

  Therefore, executable code in data sections should be moved to a code
  section, or the data section containing the executable code should be
  explicitly marked as executable. The executable attribute,
  IMAGE_SCN_MEM_EXECUTE (0x20000000), should be added to the
  Characteristics field of the corresponding section header for sections
  that contain executable code.

OTOH, I tried

  objcopy --set-section-flags .CRT=contents,alloc,load,code \
	  --set-section-flags .tls=contents,alloc,load,code \
	  setup.exe x.exe

and the resulting x.exe still crashes with the same error.  Sigh.


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

More information about the Cygwin-apps mailing list