[LLVMdev] FW: generating ELF files on non-ELF platforms with MC

Bendersky, Eli eli.bendersky at intel.com
Mon Jan 9 02:10:20 PST 2012


Ping,
Apart from Anton's concerns (which I think are manageable) and Micah's support, I received no reply on this.

Does there exist a way to tell MC to generate and ELF container for code on Windows? If not, I'm willing to submit a patch to fix this, but would like some opinions on the best direction to take here.

The proposed "llvm::TargetSpec class" (http://nondot.org/sabre/LLVMNotes/TargetSpec.txt) seems to address this, although AFAICS the current llvm::Triple does not explicitly specify the object/container type. ELF is usually taken as "default" when no other option is chosen. A representative example from X86MCTargetDesc.cpp:

---------------
static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
                                    MCContext &Ctx, MCAsmBackend &MAB,
                                    raw_ostream &_OS,
                                    MCCodeEmitter *_Emitter,
                                    bool RelaxAll,
                                    bool NoExecStack) {
  Triple TheTriple(TT);

  if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
    return createMachOStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll);

  if (TheTriple.isOSWindows())
    return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);

  return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
}
---------------

Would it be OK to add "ELF" to Triple::EnvironmentType? It seems like a plausible choice since MachO is there. On the other hand, I'm not sure whether it makes sense to make it mutually exclusive with the other members of EnvironmentType (GNU, GNUEABI, EABI).

Eli




From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Bendersky, Eli
Sent: Wednesday, January 04, 2012 13:17
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] generating ELF files on non-ELF platforms with MC

Hello,

We're currently working on MC-JIT, focusing on runtime generation and loading of ELF object files, even on non-ELF platforms (i.e. Windows). However, we run into a problem with MC insisting to generate COFF objects on Windows, MachO on Macs and ELF only otherwise, based on the triple.

Is there an existing method to generate ELF objects with MC on Windows, without modifying MC?

Thanks in advance,
Eli
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the llvm-dev mailing list