[PATCH] D129175: [ORC] Add AutoClaimWeakHiddenSymbols option in RTDyldObjectLinkingLayer.
Sunho Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 01:40:00 PDT 2022
sunho updated this revision to Diff 442464.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129175/new/
https://reviews.llvm.org/D129175
Files:
llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
Index: llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -108,6 +108,7 @@
// filter these later.
auto InternalSymbols = std::make_shared<std::set<StringRef>>();
{
+ SymbolFlagsMap ExtraSymbolsToClaim;
for (auto &Sym : (*Obj)->symbols()) {
// Skip file symbols.
@@ -128,6 +129,33 @@
return;
}
+ // Try to claim responsibility of weak hidden symbols
+ // if AutoClaimWeakHiddenSymbols flag is set.
+ if (AutoClaimWeakHiddenSymbols &&
+ (*SymFlagsOrErr & object::BasicSymbolRef::SF_Weak) &&
+ (*SymFlagsOrErr & object::BasicSymbolRef::SF_Hidden)) {
+ auto SymName = Sym.getName();
+ if (!SymName) {
+ ES.reportError(SymName.takeError());
+ R->failMaterialization();
+ return;
+ }
+
+ // Already included in responsibility set, skip it
+ if (R->getSymbols().count(ES.intern(*SymName)))
+ continue;
+
+ auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
+ if (!SymFlags) {
+ ES.reportError(SymFlags.takeError());
+ R->failMaterialization();
+ return;
+ }
+
+ ExtraSymbolsToClaim[ES.intern(*SymName)] = *SymFlags;
+ continue;
+ }
+
// Don't include symbols that aren't global.
if (!(*SymFlagsOrErr & object::BasicSymbolRef::SF_Global)) {
if (auto SymName = Sym.getName())
@@ -139,6 +167,13 @@
}
}
}
+
+ if (!ExtraSymbolsToClaim.empty()) {
+ if (auto Err = R->defineMaterializing(ExtraSymbolsToClaim)) {
+ ES.reportError(std::move(Err));
+ R->failMaterialization();
+ }
+ }
}
auto MemMgr = GetMemoryManager();
Index: llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
+++ llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
@@ -118,6 +118,18 @@
return *this;
}
+ /// If set, this RTDyldObjectLinkingLayer instance will claim responsibility
+ /// for any weak hidden symbols provided by a given object file that were not
+ /// already in the MaterializationResponsibility instance. Setting this flag
+ /// allows to expose certain weak hidden symbols inserted later in the MC
+ /// pipeline. A notalbe example is DW.ref. symbols which are emitted as weak
+ /// hidden in ppc linux enviornment. (i.e. DW.ref.__gxx_personality_v0)
+ RTDyldObjectLinkingLayer &setAutoClaimResponsibilityForWeakHiddenSymbols(
+ bool AutoClaimWeakHiddenSymbols) {
+ this->AutoClaimWeakHiddenSymbols = AutoClaimWeakHiddenSymbols;
+ return *this;
+ }
+
/// Register a JITEventListener.
void registerJITEventListener(JITEventListener &L);
@@ -150,6 +162,7 @@
bool ProcessAllSections = false;
bool OverrideObjectFlags = false;
bool AutoClaimObjectSymbols = false;
+ bool AutoClaimWeakHiddenSymbols = false;
DenseMap<ResourceKey, std::vector<MemoryManagerUP>> MemMgrs;
std::vector<JITEventListener *> EventListeners;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129175.442464.patch
Type: text/x-patch
Size: 3307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220706/63cac0db/attachment.bin>
More information about the llvm-commits
mailing list