[LLVMdev] Linkage question

Vania Joloboff vania.joloboff at inria.fr
Tue Mar 12 19:44:00 PDT 2013


Hi,

We are new in LLVM...
We want to execute JIT'ed code that links to functions inside our 
application
For example, the JIT has compiled code like

extern void open_device(Device * dev);
int foo_bar() { Device dev; ... ; open_device(&dev); ...;}
/
/where open_device() is a function in our own code, that
has initialized and called the ExecutionEngine.
Of course when running we get the error message

LLVM ERROR: Program used external function open_device which could not 
be resolved!

How can we dynamically resolve such external addresses ?
We have seen in the documentation llvm is trying to link
unresolved symbols with dlsym(). In this case it fails.
Is there a hook we can plug in the execution engine so that we control 
ourselves
the resolution of external symbols after dlsym() has failed.
We still want to try dlsym() first and only when it fails then take 
control.

We do not see this in the execution engine interface.
Of course we want to do the resolution only once upon the first call
not for each call to foo_bar() like a profiling listener would do.

Comments will be appreciated...
Vania








-- 
-- Vania Joloboff




More information about the llvm-dev mailing list