[llvm] r278149 - Re-apply r278065 (Weak symbol support in RuntimeDyld) with a fix for ELF.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 12:27:17 PDT 2016
Author: lhames
Date: Tue Aug 9 14:27:17 2016
New Revision: 278149
URL: http://llvm.org/viewvc/llvm-project?rev=278149&view=rev
Log:
Re-apply r278065 (Weak symbol support in RuntimeDyld) with a fix for ELF.
Added:
llvm/trunk/test/ExecutionEngine/MCJIT/Inputs/weak-function-2.ll
- copied unchanged from r278068, llvm/trunk/test/ExecutionEngine/MCJIT/Inputs/weak-function-2.ll
llvm/trunk/test/ExecutionEngine/MCJIT/weak-function.ll
- copied unchanged from r278068, llvm/trunk/test/ExecutionEngine/MCJIT/weak-function.ll
llvm/trunk/test/ExecutionEngine/OrcMCJIT/Inputs/weak-function-2.ll
- copied unchanged from r278068, llvm/trunk/test/ExecutionEngine/OrcMCJIT/Inputs/weak-function-2.ll
llvm/trunk/test/ExecutionEngine/OrcMCJIT/weak-function.ll
- copied unchanged from r278068, llvm/trunk/test/ExecutionEngine/OrcMCJIT/weak-function.ll
Modified:
llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h?rev=278149&r1=278148&r2=278149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h Tue Aug 9 14:27:17 2016
@@ -116,11 +116,13 @@ class OrcMCJITReplacement : public Execu
LinkingResolver(OrcMCJITReplacement &M) : M(M) {}
JITSymbol findSymbol(const std::string &Name) override {
- return M.findMangledSymbol(Name);
+ return M.ClientResolver->findSymbol(Name);
}
JITSymbol findSymbolInLogicalDylib(const std::string &Name) override {
- return M.ClientResolver->findSymbol(Name);
+ if (auto Sym = M.findMangledSymbol(Name))
+ return Sym;
+ return M.ClientResolver->findSymbolInLogicalDylib(Name);
}
private:
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=278149&r1=278148&r2=278149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Aug 9 14:27:17 2016
@@ -226,6 +226,24 @@ RuntimeDyldImpl::loadObjectImpl(const ob
// Compute JIT symbol flags.
JITSymbolFlags JITSymFlags = JITSymbolFlags::fromObjectSymbol(*I);
+ // If this is a weak definition, check to see if there's a strong one.
+ // If there is, skip this symbol (we won't be providing it: the strong
+ // definition will). If there's no strong definition, make this definition
+ // strong.
+ if (JITSymFlags.isWeak()) {
+ // First check whether there's already a definition in this instance.
+ // FIXME: Override existing weak definitions with strong ones.
+ if (GlobalSymbolTable.count(Name))
+ continue;
+ // Then check the symbol resolver to see if there's a definition
+ // elsewhere in this logical dylib.
+ if (auto Sym = Resolver.findSymbolInLogicalDylib(Name))
+ if (Sym.getFlags().isStrongDefinition())
+ continue;
+ // else
+ JITSymFlags &= ~JITSymbolFlags::Weak;
+ }
+
if (Flags & SymbolRef::SF_Absolute &&
SymType != object::SymbolRef::ST_File) {
uint64_t Addr = 0;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=278149&r1=278148&r2=278149&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Tue Aug 9 14:27:17 2016
@@ -1258,6 +1258,7 @@ RuntimeDyldELF::processRelocationRef(
break;
}
case SymbolRef::ST_Data:
+ case SymbolRef::ST_Function:
case SymbolRef::ST_Unknown: {
Value.SymbolName = TargetName.data();
Value.Addend = Addend;
More information about the llvm-commits
mailing list