Generate PE\COFF file with ARM instructions

Hi guys,

I have a question about the LLVM ARM backend:

I try to build *.c files for Windows Phone (Windows 8) - so, basically I need to generate an “arm-pe” file (I think it has the same file structure like x86-pe file, but i am not sure).
unfortunately, LLVM has no support with ARM PE\COFF.

Any ideas?
How difficult is to add the support in this file format? (LLC can generate ARM assembly, and PE\COFF files…) is there any fundamental difference between those file types (ARM-PE \ x86-PE) ?

Thanks,
Nir

Moshe, Nir wrote:
[...]

I have a question about the LLVM ARM backend:

I try to build *.c files for Windows Phone (Windows 8) - so, basically
I need to generate an "arm-pe" file (I *think* it has the same file
structure like x86-pe file, but i am not sure).
unfortunately, LLVM has no support with ARM PE\COFF.

We recently ran into this. Unfortunately there's no binutils support for
ARM PE/COFF (at least the last time I looked).

It doesn't seem to be very hard to add; from what I found out, the only
real difference is a difference to the CPU type field. But binutils is
sufficiently painful to wrangle that I couldn't do it in a few hours, so
we went for other tools.

With binutils support adding ARM PE/COFF should be fairly easy,
depending on how much the ABI has changed from ARM EABI.

It doesn't seem to be very hard to add; from what I found out, the only
real difference is a difference to the CPU type field. But binutils is
sufficiently painful to wrangle that I couldn't do it in a few hours, so
we went for other tools.

The relocations are probably almost all different too. I couldn't find
any specification (they're probably undocumented) you can get an idea
of the work required from the ELF equivalent:

LLVM itself doesn't have to support all of the relocations defined
(just a sufficiently powerful subset to describe any program) but
binutils (specifically ld and to a lesser extent gas) theoretically
needs to handle each and every one.

You might be able to get away with less, but it's dodgy from a
neatness point of view: a compiler could claim
implementation-decision; a linker would be clearly ABI non-compliant.

Nothing impossible, of course, but more than a quick evening's job
even for someone who knew the code inside-out.

Cheers.

Tim.

I don't remember the exact version it happened, but right after the Windows RT / Windows Phone 8 stuff was announced and it became known that native apps were possible, I seem to remember GCC removing support for ARM/PE. I don't know if this was related to binutils removing it or if it was strictly gcc related, but you may have better luck hacking it into a pre-2012 version.

-Gordon

Hi,