GCC PE support

Jim Wilson jimw@sifive.com
Mon Jun 24 20:10:00 GMT 2019


On Sun, Jun 23, 2019 at 1:49 PM valerij zaporogeci <vlrzprgts@gmail.com> wrote:
> thank you. I meant - would it be feasible to _add_ to gcc needed
> pieces to make existing PE support (for x86 WinAPI target) available
> for at least MIPS32? and if so, where to start from? :)

You first need to add code to parse and recognize dllimport and
dllexport, then you need to mark functions so that they can be handled
specially, then you need code to recognize the marked functions and
handle them differently.  Exactly how the last part works will depend
on the target ABI(s), but the first two parts should be easy.  You may
also need binutils support in the assembler and linker to handle any
new assembler syntax or relocations needed to make this work.
declspec probably needs to be a macro that expands to __attribute__.

I'd start by copying code from one of the arm/mcore/i386 ports.  The
i386 port is probably the most complicated one, so looking at mcore or
arm may be easier.  Start by looking for mentions of dllimport and
dllexport in the backends, and then write similar code for the
MIPS/PPC ports.  You may also want to look at old gcc versions to see
if maybe you can find one that had the support, and then try to port
it forward to a more recent gcc source tree.  Either way you will need
to learn a bit about gcc (and maybe also binutils) internals to make
this work.

Jim



More information about the Gcc-help mailing list