[LLVMdev] linking individual functions in execution module

charles quarra charllsnotieneningunputocorreo at gmail.com
Sun Dec 2 18:45:31 PST 2012


2012/11/26 Kaylor, Andrew <andrew.kaylor at intel.com>:
> What I was thinking is that if you need to link to module A to functions in module B (which you know might be re-JITed) you can have a stub function that gets used as the address called by module A and then you can use some brute force approach to maintain the actual address of the function in module B as it is re-JITed (maybe the stub could be a lightweight class with a member variable that's kept up-to-date or whatever).  The problem I'm trying to solve with this approach is that once you return the address of a function from the memory manager's getPointerToNamed function, the address you return is going to be written into the JITed code as part of the linking process, so you need a central location to maintain updates to that address.
>
> Your approach of linking with a cloned copy of the module (before JITing?) would work too.  The main downside I see to that is you may end up JITing multiple copies of functions in the cloned module.  That may be OK.  Something very similar was done in a project I worked on here at Intel and the results were good.
>

suppose module B has call/InvokeInst to calls in module A
after i clone both modules i get B' and A'
my concrete question is this:
Are there any special steps that i need to do before linking the
modules B' and A' together?

my main concern is that B' will have call/InvokeInst pointing to
module A, not A', and the linker will not be able to notice that it
should replace A' references with A

any suggestions about this are greatly welcome




More information about the llvm-dev mailing list