[LLVMdev] Primer with LLVM

Misha Brukman brukman at uiuc.edu
Fri Dec 31 10:20:08 PST 2004

On Fri, Dec 31, 2004 at 02:30:00PM +0100, Francisco Puentes wrote:
> Now I have other problem: I have a Module and I need generate a
> iostream (memory) with native x86 code (maybe elf/coff) to be executed
> later (into the guest process space, without fork!!). I studied llc
> and lli, but they don't help me much. Any idea? Are there any guy
> working in some like that?

In addition to what Reid said, I would like to point out that
llvm/tools/lli/lli.cpp is not the entire JIT compiler, a lot of it lives
in llvm/lib/ExecutionEngine/* and llvm/lib/ExecutionEngine/JIT/* .
Together, they provide a lot of the machinery that you're looking for.

The other point is that the JIT, when it writes out code to memory, is
no longer relocatable, i.e. it's bound to the addresses where it's
written, with all symbol references resolved.  LLVM does support
relocations, but if you need to save binary code and then load it in
different address spaces, or write out elf/coff binaries directly, you
will need to do some work such as creating a BinaryObjectCodeEmitter (to
parallel the current MachineCodeEmitter) and properly write out the
correct binary image, with relocations intact.

Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu

More information about the llvm-dev mailing list