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
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 5d5ecc4..6cd1c50 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -509,16 +509,17 @@
<< "' from bitcode file: " << ErrorMsg << "\n";
abort();
}
- }
- if (void *Addr = getPointerToGlobalIfAvailable(F)) {
- return Addr;
+ // Now retry to get the address.
+ if (void *Addr = getPointerToGlobalIfAvailable(F))
+ return Addr;
}
MutexGuard locked(lock);
if (F->isDeclaration()) {
- void *Addr = getPointerToNamedFunction(F->getName());
+ bool AbortOnFailure = F->getLinkage() != GlobalValue::ExternalWeakLinkage;
+ void *Addr = getPointerToNamedFunction(F->getName(), AbortOnFailure);
addGlobalMapping(F, Addr);
return Addr;
}