[LLVMdev] Relocatability of LLVM code

Chris Lattner clattner at apple.com
Thu Aug 20 10:33:07 PDT 2009


On Aug 20, 2009, at 10:02 AM, Reid Kleckner wrote:

>> What I need to know is, is the native code generated by LLVM
>> relocatable such that it could be copied to another location in  
>> memory
>> like this?  Also, does LLVM do anything to the native code after it  
>> is
>> first emitted?  Does it try rewriting it, for example?
>
> That's a good question, and I wish I knew the answer, because if that
> were the case the entire memory manager could be dramatically
> simplified to emit code into a resizeable buffer (like a BinaryObject
> or std::vector<uint8_t>), copy the code into place (wherever the
> memory manager wants it to go), and then apply the relocations.

I would really like to get to this point, but the JIT just isn't  
designed that way.  Logically, the output of the backend is machine  
code bytes + relocations.  In practice, we don't have this clean  
separation right now. I'm hoping that the MC stuff we're doing will  
help get us in this direction.

-Chris



More information about the llvm-dev mailing list