[PATCH] fix objcopy PE -> ELF conversion

Christian Franke Christian.Franke@t-online.de
Tue Oct 23 22:48:00 GMT 2007


Daniel Jacobowitz 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.
>> (http://sourceware.org/bugzilla/show_bug.cgi?id=970)
>>     
>
> As HJ said, this should be done in BFD, not in objcopy.c.  Maybe the
> generic BFD_RELOC_32_PCREL should not be used for the slightly
> different PE semantics?  That'd prevent BFD making the conversion.
>
>   

Another alternative would be to keep BFD_RELOC_32_PCREL and let 
bfd_canonicalize_reloc() return arelent.addend = -4 for these entries.
Then the backend can detect the nonzero addend and fail for variants 
without addend in the symbol table (or better fixup section data later 
to support the conversion :-). But apparently the ELF-backend simply 
ignores the addend in this case.

The -4 offset is hard-coded in the COFF_WITH_PE part, therefore it might 
be very complex to fix this in BFD.

I probably better provide a separate conversion utility to build GRUB2 
modules on Cygwin :-)

Christian



More information about the Binutils mailing list