creating working PE file with BFD

peter matula xmatul01@stud.fit.vutbr.cz
Tue Jul 27 11:53:00 GMT 2010
On 23.07.2010 12:53, peter matula wrote:
> Hello, I have yet another PE related question.
>
> I made program using BFD for transformation of ELF files to our internal
> binary format (working name - COFF because it is text representation of
> binary formats similar to COFF) and backwards. It works fine and
> executable file created by conversion ELF->COFF->ELF is all right.
>
> Now I would like to transform other binary formats, starting PE. I was
> very pleased when I found pei-i386 in BFD target list. So I made little
> change in coff2elf module like this:
> --- m_pBfd = bfd_openw(m_sElfOutputFile.c_str(), "elf32-i386");
> +++ m_pBfd = bfd_openw(m_sElfOutputFile.c_str(), "pei-i386");
> and left everything other untouched. I transformed PE->COFF->PE and try
> to run output file. It didn't work but at least it created PE file not
> so different from original. Analysis shows that biggest differences are
> in "NT additional fields" and output PE has problem to get to Import
> Table in .idata section (objdump -p hello.exe).
>
> Here are outputs by AnywherePEViewer:
> http://www.2shared.com/file/abisocMJ/pe_view.html
>
> So my questions are:
> Is BFD able to create valid PE file in general ?
> Has someone experience doing something similar, any advices ?
> What other changes are nessesary except changing target ? and how is
> creating PE by BFD different from creating ELF ?
> Do you know about some materials that can help ?
>
> I would be really glad if it would be possible to use already programmed
> elf2coff and coff2elf modules with some changes instead of programing
> separate programs using pelib or something else.
>
> Peter Matula

No one can help with: How is creating PE by BFD different from creating 
ELF ?

Peter Matula



More information about the Binutils mailing list