[LLVMdev] MCJIT fully position independent code, and the runtime linker

Lang Hames lhames at gmail.com
Mon May 4 11:21:52 PDT 2015


Hi Dave,

MCJIT uses the MC layer to produce a relocatable object file for JIT'd LLVM
IR. Even if you use PIC and have fully resolved all external references at
the IR level this object file may still contain relocations for internal
symbols which the runtime linker must resolve.

Some clients also like having the runtime linker resolve external symbols
because it allows them to cache JIT'd object files are re-use them in
subsequent JIT sessions.

Cheers,
Lang.


On Wed, Apr 22, 2015 at 8:30 PM, Dave Pitsbawn <dpitsbawn at gmail.com> wrote:

> Hello,
>
> I wanted to know why is there a need for a runtime linker if LLVM can
> produce fully relocatable code?
>
> That is, if I ask MCJIT to generate code that uses PC-rel offsets for
> everything, why would I need a runtime linker at all?
>
> Is it for name resolution or something I don't get?
>
> To me the JIT seems like an API that can produce assembly that I should be
> able to load where-ever I feel like. Only think I can think of is that if I
> encounter a call instruction I better have an address to give it to. But
> other than that ...
>
> What is preventing this from happening? I'm sure it's my limited
> understanding of the linker space, but I would love to understand.
>
> Dave
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150504/5f13147f/attachment.html>


More information about the llvm-dev mailing list