how to emit win32/64 code to elf object file


This is what I'd like to do: I generate some code, compile it and write it to a elf object file.
then I read the code out of the elf, do the relocation by hand and execute it. the problem
is when I have a win32/64 target that has a different calling convention on x64 I'd like
to also emit an elf instead of a coff. currently windows targets automatically generate a coff.
is there a way to override this? i.e. compiling with win calling convention and writing to elf