This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] fix objcopy PE -> ELF conversion
- From: Christian Franke <Christian dot Franke at t-online dot de>
- To: "H.J. Lu" <hjl at lucon dot org>
- Cc: binutils at sourceware dot org
- Date: Mon, 22 Oct 2007 21:52:10 +0200
- Subject: Re: [PATCH] fix objcopy PE -> ELF conversion
- References: <471CF3CF.firstname.lastname@example.org> <20071022191916.GA13752@lucon.org>
H.J. Lu wrote:
On Mon, Oct 22, 2007 at 09:02:39PM +0200, Christian Franke wrote:
Objcopy cannot convert pe-i386 to elf32-i386. The offsets of the
pc-relative relocation entries are not converted properly.
I need some PE to ELF conversion for the Cygwin port of GRUB2. The first
working Cygwin patch for GRUB2 includes a workaround to load the broken
ELF modules produced by objcopy. It would be desirable to fix this in
There is nothing wrong with objcopy. GRUB2 should be fixed instead.
The ELF loader of GRUB2 is IMO OK.
"objcopy -O elf32-i386 pe-file.o elf-file.o" definitly produces bad
pc-relative relocation with offset 4. There are some provisions in the
BFD COFF_WITH_PE code to fix the offset later in the executable. But
this has no effect when converting relocatable modules.
You should be to link PECOFF .o files with ELF .o files to generate
GRUB2 requires relocatable (ld -r ...) ELF modules.
And ld does not support "--oformat elf32-i386" for PE input files
("ld: cannot perform PE operations on non PE output file ...")