LLVM 抖动可以在连续内存地址中发出本机代码吗?
我有关于 LLVM 抖动的问题: 我可以强制 LLVM 抖动在连续内存地址中发出本机代码吗?并成为 PIC ? 我想做的是将 JIT 代码保存在文件中并加载它以供稍后执行..
我所说的“加载”的意思是简单地将文件中的位读取到缓冲区中我不想生成 elf 或其他东西像这样。
这是一个例子: 假设我有 C 源文件,其中包含:
Global variables
----------------
Function Foo()
----------------
Function Too()
当我请求 JIT 代码时,我希望 JIT 位于连续内存地址中:
0x100: Global Vars (take 16 Byte)
0x110: Foo() Code (take 32 Byte)
0x130: Too() Code (take 32 Byte)
0x150: end.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将 JIT 代码存储在内存的某些区域,您可以编写特殊版本的 JITMemoryManager (
include/llvm/ExecutionEngine/JITMemoryManager.h
lib/ExecutionEngine/JIT/JITMemoryManager.cpp
)。这里有一个自定义 JIM MM 的示例:unittests/ExecutionEngine/JIT/JITTest.cpp
,它是一个RecordingJITMemoryManager
,用于记录主要 JIT MM 调用。正如我所看到的(如 LLVM 2.9),ARM JIT 将
isPIC
设置为 False,并且 X86 JIT 能够生成 PIC 代码。最大的问题似乎是预编译代码的加载。
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 anRecordingJITMemoryManager
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.