Can LLVM jitter emit native code in continent memory addresses?

I have a question regarding LLVM Jitter: Can I get LLVM Jitter to emit native code in read-only memory addresses? and be a pic? what I want to do is move the saved JIT code to a file and load it for execution later ..

what I mean by β€œload” is just to read bits from a file into the buffer, I don’t want to generate an elf or something like that.

Here is an example: suppose I have a C source file that contains:

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

when I request a JIT code, I want the JIT to be in the memory addresses of the continuum:

 0x100: Global Vars (take 16 Byte) 0x110: Foo() Code (take 32 Byte) 0x130: Too() Code (take 32 Byte) 0x150: end. 
+6
source share
1 answer

To save the JIT code in some memory area, you can write a special version of the JITMemoryManager ( include/llvm/ExecutionEngine/JITMemoryManager.h lib/ExecutionEngine/JIT/JITMemoryManager.cpp ). The following is an example of a custom JIM MM: unittests/ExecutionEngine/JIT/JITTest.cpp , this is a RecordingJITMemoryManager that records the main JIT MM calls.

As I can see (like LLVM 2.9), ARM isPIC have isPIC set to False, and the X86 JIT is able to generate PIC code.

The biggest problem seems to be loading pre-compiled code.

+7
source

Source: https://habr.com/ru/post/891378/


All Articles