Index: include/llvm/ExecutionEngine/ExecutionEngine.h =================================================================== --- include/llvm/ExecutionEngine/ExecutionEngine.h (revision 47531) +++ include/llvm/ExecutionEngine/ExecutionEngine.h (working copy) @@ -208,7 +208,7 @@ /// getGlobalValueAtAddress - Return the LLVM global value object that starts /// at the specified address. /// - const GlobalValue *getGlobalValueAtAddress(void *Addr); + virtual const GlobalValue *getGlobalValueAtAddress(void *Addr); void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, const Type *Ty); Index: lib/ExecutionEngine/JIT/JITEmitter.cpp =================================================================== --- lib/ExecutionEngine/JIT/JITEmitter.cpp (revision 47531) +++ lib/ExecutionEngine/JIT/JITEmitter.cpp (working copy) @@ -130,6 +130,13 @@ return (void*)(intptr_t)LazyResolverFn; } + /// getFunctionStubForAddr - Return the function pointer for a + /// stub function. + Function *getFunctionStubForAddr(void *Addr) { + MutexGuard locked(TheJIT->lock); + return state.getStubToFunctionMap(locked)[Addr]; + } + /// getGOTIndexForAddress - Return a new or existing index in the GOT for /// an address. This function only manages slots, it does not manage the /// contents of the slots or the memory associated with the GOT. @@ -765,6 +772,19 @@ return JE->getJITResolver().getFunctionStub(F); } +/// getGlobalValueAtAddress - Extended to include stub functions, if our +/// parent implementation can not find a value for Addr. +const GlobalValue *JIT::getGlobalValueAtAddress(void *Addr) { + const GlobalValue *GV = ExecutionEngine::getGlobalValueAtAddress(Addr); + if (GV) + return GV; + + assert(dynamic_cast(MCE) && "Unexpected MCE?"); + JITEmitter *JE = static_cast(getCodeEmitter()); + return JE->getJITResolver().getFunctionStubForAddr(Addr); +} + + /// freeMachineCodeForFunction - release machine code memory for given Function. /// void JIT::freeMachineCodeForFunction(Function *F) { Index: lib/ExecutionEngine/JIT/JIT.h =================================================================== --- lib/ExecutionEngine/JIT/JIT.h (revision 47531) +++ lib/ExecutionEngine/JIT/JIT.h (working copy) @@ -81,6 +81,11 @@ virtual GenericValue runFunction(Function *F, const std::vector &ArgValues); + + /// getGlobalValueAtAddresss - Overridden to handle stub functions. + /// + const GlobalValue *getGlobalValueAtAddress(void *Addr); + /// getPointerToNamedFunction - This method returns the address of the /// specified function by using the dlsym function call. As such it is only /// useful for resolving library symbols, not code generated symbols.