I don't know if this report belongs here or if I should report a binutils bug, but I'll start here.

When building emacs-w32.exe with the current binutils, I end up with an executable that won't run after it's stripped (at least on x86_64). I traced this to the fact that emacs-w32 comes with its own manifest. My understanding is that the emacs-w32 manifest should take precedence over the Cygwin default manifest, but something's going wrong in this case.

Here's a simple test case to illustrate the problem, using a slight modification of the resource file that comes with emacs, and the corresponding manifest (see attached).

$ windres -O coff emacs.rc -o emacs.res

$ cat test.c
int main()
{
  return 0;
}

$ gcc -o test test.c -Wl,emacs.res

$ strip test.exe

$ ./test.exe
bash: ./test.exe: cannot execute binary file

The stripped binary has a messed up .rsrc section:

$ objdump -j .rsrc -s test.exe

test.exe:     file format pei-x86-64

Contents of section .rsrc:
objdump: Reading section failed


Ken
1 24 "emacs-x64.manifest"

#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 1
#endif

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 24,3,50,0
 PRODUCTVERSION 24,3,50,0
 FILEFLAGSMASK 0x3FL
#ifdef EMACSDEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904B0"
        BEGIN
            VALUE "CompanyName", "Free Software Foundation\0"
            VALUE "FileDescription", "GNU Emacs: The extensible 
self-documenting text editor\0"
            VALUE "FileVersion", "24, 3, 50, 0\0"
            VALUE "InternalName", "Emacs\0"
            VALUE "LegalCopyright", "Copyright (C) 2001-2014\0"
            VALUE "OriginalFilename", "emacs.exe"
            VALUE "ProductName", "Emacs\0"
            VALUE "ProductVersion", "24, 3, 50, 0\0"
            VALUE "OLESelfRegister", "\0"
         END
     END
     BLOCK "VarFileInfo"
     BEGIN
         VALUE "Translation", 0x409, 1200
     END
END
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
                        version="6.0.0.0" processorArchitecture="AMD64"
                        publicKeyToken="6595b64144ccf1df"
                        language="*"/>
    </dependentAssembly>
  </dependency>
  <assemblyIdentity version="1.0.0.0" processorArchitecture="AMD64"
		    name="emacs" type="win32"/>
  <description>GNU Emacs</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
      <application> 
         <!-- Windows 8.1 -->
         <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
         <!-- Windows Vista -->
         <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
         <!-- Windows 7 -->
         <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
         <!-- Windows 8 -->
         <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      </application> 
    </compatibility>
</assembly>

--
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

Reply via email to