diff options
author | Dan Gohman <gohman@apple.com> | 2009-01-05 05:32:42 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-01-05 05:32:42 +0000 |
commit | 69f9378675b23135043d93aa58300fed3ec41cbf (patch) | |
tree | 81d5c99a3387d8c274c61443fae54f8e8006d6dc /lib/ExecutionEngine/JIT/JITEmitter.cpp | |
parent | 1c7a81b0c5cbc982755e1a4dca9d1726f3f5c1c0 (diff) |
Handle weak_extern in the JIT. This fixes
SingleSource/UnitTests/2007-04-25-weak.c in JIT mode. The test
now passes on systems which are able to produce a correct
reference output to compare with.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JITEmitter.cpp')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index e041767f8f..3f3f681f61 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -177,9 +177,14 @@ void *JITResolver::getFunctionStub(Function *F) { // Call the lazy resolver function unless we already KNOW it is an external // function, in which case we just skip the lazy resolution step. void *Actual = (void*)(intptr_t)LazyResolverFn; - if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) + if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) { Actual = TheJIT->getPointerToFunction(F); + // If we resolved the symbol to a null address (eg. a weak external) + // don't emit a stub. Return a null pointer to the application. + if (!Actual) return 0; + } + // Otherwise, codegen a new stub. For now, the stub will call the lazy // resolver function. Stub = TheJIT->getJITInfo().emitFunctionStub(F, Actual, @@ -905,7 +910,8 @@ bool JITEmitter::finishFunction(MachineFunction &F) { void *ResultPtr = 0; if (!MR.letTargetResolve()) { if (MR.isExternalSymbol()) { - ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol()); + ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol(), + false); DOUT << "JIT: Map \'" << MR.getExternalSymbol() << "\' to [" << ResultPtr << "]\n"; |