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

Bendersky, Eli eli.bendersky at intel.com
Mon Jan 9 05:13:49 PST 2012


James,

Thanks for the input. As the code sample I pasted shows, currently the container is directly inferred from the triple, looking at its "OSType" enum, with the exception of MachO also being selected based on getEnvironment() == Triple::MachO. The Triple seems to be the ubiquitous "configuration" object being passed around, according to which the container is eventually chosen.

The new llvm::TargetSpec class proposed in  http://nondot.org/sabre/LLVMNotes/TargetSpec.txt also (explicitly) carries the container around.

Unfortunately I'm not familiar enough with these areas of the code to have a good idea of what alternatives there are to specify the container for MC. I'll be happy to hear any suggestions.

It could be we just need a temporary solution until llvm::TargetSpec is implemented. 

Eli

-----Original Message-----
From: James Molloy [mailto:james.molloy at arm.com] 
Sent: Monday, January 09, 2012 13:13
To: Bendersky, Eli; llvmdev at cs.uiuc.edu
Subject: RE: generating ELF files on non-ELF platforms with MC

Hi,

> 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).

EABI and GNUEABI imply ELF. GNU in practice does not need to imply ELF, but is used in the ARM world as "the pre AAPCS ABI". I'm not certain, but I don't think EnvironmentType is even used on non-ARM platforms, so you could add an extra enumerator without affecting anything.

That said, I don't think the container is a property of the triple or even the target selection. For example, we could generate flat-binary or ELF output on ELF systems.

Some solution that doesn't tie the output format to the target would be better, IMHO.

Cheers,

James

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Bendersky, Eli
Sent: 09 January 2012 10:10
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] FW: generating ELF files on non-ELF platforms with MC

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.


_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




---------------------------------------------------------------------
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