diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:40 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-09-05 16:50:40 +0000 |
commit | 35ed842773da41779d57d3ed23f440202d0be198 (patch) | |
tree | 1145a37b7143d8a20323ad54629e7cf3d9c14500 /lib/ExecutionEngine/MCJIT | |
parent | 706f03a35db7029b2dbd2925552eb0d0472dcbb4 (diff) | |
download | llvm-35ed842773da41779d57d3ed23f440202d0be198.tar.gz llvm-35ed842773da41779d57d3ed23f440202d0be198.tar.bz2 llvm-35ed842773da41779d57d3ed23f440202d0be198.tar.xz |
MCJIT: getPointerToFunction() references target address space.
Make sure to return a pointer into the target memory, not the local memory.
Often they are the same, but we can't assume that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/MCJIT')
-rw-r--r-- | lib/ExecutionEngine/MCJIT/MCJIT.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 99c65ecf95..fa71305145 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -113,6 +113,11 @@ void *MCJIT::getPointerToBasicBlock(BasicBlock *BB) { } void *MCJIT::getPointerToFunction(Function *F) { + // FIXME: This should really return a uint64_t since it's a pointer in the + // target address space, not our local address space. That's part of the + // ExecutionEngine interface, though. Fix that when the old JIT finally + // dies. + // FIXME: Add support for per-module compilation state if (!isCompiled) emitObject(M); @@ -126,10 +131,13 @@ void *MCJIT::getPointerToFunction(Function *F) { // FIXME: Should the Dyld be retaining module information? Probably not. // FIXME: Should we be using the mangler for this? Probably. + // + // This is the accessor for the target address, so make sure to check the + // load address of the symbol, not the local address. StringRef BaseName = F->getName(); if (BaseName[0] == '\1') - return (void*)Dyld.getSymbolAddress(BaseName.substr(1)); - return (void*)Dyld.getSymbolAddress((TM->getMCAsmInfo()->getGlobalPrefix() + return (void*)Dyld.getSymbolLoadAddress(BaseName.substr(1)); + return (void*)Dyld.getSymbolLoadAddress((TM->getMCAsmInfo()->getGlobalPrefix() + BaseName).str()); } |