[LLVMdev] jit with external functions
Chris Lattner
sabre at nondot.org
Sat Dec 9 10:57:36 PST 2006
On Sat, 9 Dec 2006, Ram Bhamidipaty wrote:
> Will it also handle symbols that are in shared libraries loaded into
> the process?
I'm not sure, but I thought so.
> I am creating a python module that has the llvm functionality. This
> module is loaded
> into the process as a shared library. I want to generate llvm assembler that has
> calls to functions in this shared library.
>
> I just tried an experiment and I got this back:
>
> ERROR: Program used external function 'rtcg_callback' which could not
> be resolved!
> Aborted
Guess not :). Are you sure that rtcg_callback isn't marked static and
isn't hidden by an export map?
> It looks like the additional shared libraries might not be searched. I
> plan on looking at the code to see if I can modify it to handle my case.
> Any suggestions on how or where I should make the change?
see llvm/lib/ExecutionEngine/JIT/Intercept.cpp:
JIT::getPointerToNamedFunction. It ends up calling:
// If it's an external function, look it up in the process image...
void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);
if (Ptr) return Ptr;
It also prepends a _ to the symbol name and tries that. Alternatively,
you can use the ExecutionEngine::addGlobalMapping to say that specific
functions/globals are at specific addresses.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list