Bug 507178

Summary: i686-pc-mingw32-readelf reports "Not an ELF file"
Product: [Fedora] Fedora Reporter: Miao ZhiCheng <hellwolf.misty>
Component: mingw32-binutilsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: berrange, erik-fedora, fedora-mingw, fedora, kevin, rjones
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-22 08:39:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miao ZhiCheng 2009-06-21 14:25:53 UTC
Description of problem:
i686-pc-mingw32-readelf reports "Not an ELF file" to the exe file produes by i686-pc-mingw32-gcc.

Version-Release number of selected component (if applicable):
mingw32-binutils-2.19.1-4.fc11.i586

How reproducible:
$ cat 1.c
#include <stdio.h>

int main()
{
    printf("hellwolf\n");
}
$ i686-pc-mingw32-gcc 1.c
$ i686-pc-mingw32-readelf -d a.exe 
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

Comment 1 Erik van Pienbroek 2009-06-21 15:36:22 UTC
What's wrong with this behaviour? Win32 executables are in the PE format instead of the ELF format so the error message is correct AFAIK.

Comment 2 Daniel Berrangé 2009-06-22 08:39:22 UTC
As Erik says, Mingw32 executes are *not* ELF files, therefore the error message from 'readelf' is correct. 

$ file virsh.exe 
virsh.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit

Comment 3 Kevin Kofler 2009-06-22 11:59:35 UTC
Why is there an i686-pc-mingw32-readelf at all? The target binaries are NOT ELF, so obviously readelf won't work, so why is upstream Binutils installing it and why are we packaging it? It doesn't make sense to ship stuff which can't work.

Comment 4 Miao ZhiCheng 2009-06-22 12:30:15 UTC
I want to know what dlls it links to, in ELF I can use readelf to get those information. What tool should I use now?

Comment 5 Thomas Sailer 2009-06-22 13:39:07 UTC
i686-pc-mingw32-objdump -x mydll.dll

will list the import section, where you can find the DLL's it imports

Comment 6 Richard W.M. Jones 2009-06-22 14:19:10 UTC
In reply to comment 3, I'm also having a hard time thinking
of a situation where i686-pc-mingw32-readelf would be
useful.  But do we really want to bother deleting it?  It
takes a miniscule amount of space in the grand scheme
of things, and might have some use to someone.