@@ -754,12 +754,6 @@ void MachOPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
754754void MachOPlatform::rt_pushSymbols (
755755 PushSymbolsInSendResultFn SendResult, ExecutorAddr Handle,
756756 const std::vector<std::pair<StringRef, bool >> &SymbolNames) {
757- LLVM_DEBUG ({
758- dbgs () << " MachOPlatform::rt_pushSymbols(" << Handle << " , [ " ;
759- for (auto &Name : SymbolNames)
760- dbgs () << " \" " << Name.first << " \" " ;
761- dbgs () << " ])\n " ;
762- });
763757
764758 JITDylib *JD = nullptr ;
765759
@@ -769,6 +763,16 @@ void MachOPlatform::rt_pushSymbols(
769763 if (I != HeaderAddrToJITDylib.end ())
770764 JD = I->second ;
771765 }
766+ LLVM_DEBUG ({
767+ dbgs () << " MachOPlatform::rt_pushSymbols(" ;
768+ if (JD)
769+ dbgs () << " \" " << JD->getName () << " \" , [ " ;
770+ else
771+ dbgs () << " <invalid handle " << Handle << " >, [ " ;
772+ for (auto &Name : SymbolNames)
773+ dbgs () << " \" " << Name.first << " \" " ;
774+ dbgs () << " ])\n " ;
775+ });
772776
773777 if (!JD) {
774778 SendResult (make_error<StringError>(" No JITDylib associated with handle " +
@@ -787,7 +791,6 @@ void MachOPlatform::rt_pushSymbols(
787791 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
788792 std::move (LS), SymbolState::Ready,
789793 [SendResult = std::move (SendResult)](Expected<SymbolMap> Result) mutable {
790- dbgs () << " Sending result pushSymbols result...\n " ;
791794 SendResult (Result.takeError ());
792795 },
793796 NoDependenciesToRegister);
@@ -813,14 +816,6 @@ void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
813816
814817 using namespace jitlink ;
815818
816- // Check for a header address.
817- {
818- std::lock_guard<std::mutex> Lock (MP.PlatformMutex );
819- auto I = MP.JITDylibToHeaderAddr .find (&MR.getTargetJITDylib ());
820- if (I != MP.JITDylibToHeaderAddr .end ())
821- HeaderAddr = I->second ;
822- }
823-
824819 bool InBootstrapPhase =
825820 &MR.getTargetJITDylib () == &MP.PlatformJD && MP.Bootstrap ;
826821
@@ -875,10 +870,10 @@ void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
875870 Config.PostPrunePasses .push_back ([this , JITSymTabInfo](LinkGraph &G) {
876871 return prepareSymbolTableRegistration (G, *JITSymTabInfo);
877872 });
878- Config.PostFixupPasses .push_back (
879- [ this , JITSymTabInfo, InBootstrapPhase](LinkGraph &G) {
880- return addSymbolTableRegistration (G, *JITSymTabInfo, InBootstrapPhase);
881- });
873+ Config.PostFixupPasses .push_back ([ this , &MR, JITSymTabInfo,
874+ InBootstrapPhase](LinkGraph &G) {
875+ return addSymbolTableRegistration (G, MR , *JITSymTabInfo, InBootstrapPhase);
876+ });
882877
883878 // Add a pass to register the final addresses of any special sections in the
884879 // object with the runtime.
@@ -1427,7 +1422,15 @@ Error MachOPlatform::MachOPlatformPlugin::registerObjectPlatformSections(
14271422 ? G.allocActions ()
14281423 : MP.Bootstrap .load ()->DeferredAAs ;
14291424
1430- assert (HeaderAddr && " No HeaderAddr for JITDylib" );
1425+ ExecutorAddr HeaderAddr;
1426+ {
1427+ std::lock_guard<std::mutex> Lock (MP.PlatformMutex );
1428+ auto I = MP.JITDylibToHeaderAddr .find (&JD);
1429+ assert (I != MP.JITDylibToHeaderAddr .end () &&
1430+ " No header registered for JD" );
1431+ assert (I->second && " Null header registered for JD" );
1432+ HeaderAddr = I->second ;
1433+ }
14311434 allocActions.push_back (
14321435 {cantFail (
14331436 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
@@ -1699,16 +1702,23 @@ Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
16991702}
17001703
17011704Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration (
1702- jitlink::LinkGraph &G, JITSymTabVector &JITSymTabInfo,
1703- bool InBootstrapPhase) {
1705+ jitlink::LinkGraph &G, MaterializationResponsibility &MR,
1706+ JITSymTabVector &JITSymTabInfo, bool InBootstrapPhase) {
1707+
1708+ ExecutorAddr HeaderAddr;
1709+ {
1710+ std::lock_guard<std::mutex> Lock (MP.PlatformMutex );
1711+ auto I = MP.JITDylibToHeaderAddr .find (&MR.getTargetJITDylib ());
1712+ assert (I != MP.JITDylibToHeaderAddr .end () && " No header registered for JD" );
1713+ assert (I->second && " Null header registered for JD" );
1714+ HeaderAddr = I->second ;
1715+ }
17041716
17051717 SmallVector<std::tuple<ExecutorAddr, ExecutorAddr, MachOExecutorSymbolFlags>>
17061718 SymTab;
1707- for (auto &[OriginalSymbol, NameSym] : JITSymTabInfo) {
1708- // dbgs() << "Original symbol: \"" << OriginalSymbol->getName() << "\"\n";
1719+ for (auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
17091720 SymTab.push_back ({NameSym->getAddress (), OriginalSymbol->getAddress (),
17101721 flagsForSymbol (*OriginalSymbol)});
1711- }
17121722
17131723 using SPSRegisterSymbolsArgs =
17141724 SPSArgList<SPSExecutorAddr,
0 commit comments