Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can LLVM jitter emit the native code in continus memory addresses?

I have question relating to LLVM Jitter: Can i obligue the LLVM Jitter to emit the native code in continuous memory addresses ? and to be PIC ? what i want to do is to move save the JIT code in a file and load it for execution later ..

what i mean by "load" is to simply read the bits from file into buffer i don't want to generate elf or something like this.

Here's an example: suppose i have C source file which contain:

Global variables
----------------
Function Foo()
----------------
Function Too()

when i request the JIT code i want the JIT to be in continus memory addresses:

0x100: Global Vars (take 16 Byte)
0x110: Foo() Code (take 32 Byte)
0x130: Too() Code (take 32 Byte)
0x150: end.
like image 729
user552285 Avatar asked Jun 26 '11 06:06

user552285


1 Answers

To store JIT'ed code in some region of memory you can write special version of JITMemoryManager (include/llvm/ExecutionEngine/JITMemoryManager.h lib/ExecutionEngine/JIT/JITMemoryManager.cpp). There is example of custom JIM MM here: unittests/ExecutionEngine/JIT/JITTest.cpp, it is an RecordingJITMemoryManager which logs main JIT MM calls.

As I can see (as LLVM 2.9), ARM JIT have isPIC set to False and X86 JIT is capable of generating PIC code.

The biggest problem, seems, is loading of precompiled code.

like image 51
osgx Avatar answered Oct 03 '22 15:10

osgx