LLVM 20.0.0git
ELFNixPlatform.cpp
Go to the documentation of this file.
1//===------ ELFNixPlatform.cpp - Utilities for executing ELFNix in Orc
2//-----===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
11
18#include "llvm/Support/Debug.h"
19#include <optional>
20
21#define DEBUG_TYPE "orc"
22
23using namespace llvm;
24using namespace llvm::orc;
25using namespace llvm::orc::shared;
26
27namespace {
28
29template <typename SPSSerializer, typename... ArgTs>
31getArgDataBufferType(const ArgTs &...Args) {
33 ArgData.resize(SPSSerializer::size(Args...));
34 SPSOutputBuffer OB(ArgData.empty() ? nullptr : ArgData.data(),
35 ArgData.size());
36 if (SPSSerializer::serialize(OB, Args...))
37 return ArgData;
38 return {};
39}
40
41std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(ELFNixPlatform &MOP,
42 std::string Name) {
43 unsigned PointerSize;
44 llvm::endianness Endianness;
45 const auto &TT = MOP.getExecutionSession().getTargetTriple();
46
47 switch (TT.getArch()) {
48 case Triple::x86_64:
49 PointerSize = 8;
50 Endianness = llvm::endianness::little;
51 break;
52 case Triple::aarch64:
53 PointerSize = 8;
54 Endianness = llvm::endianness::little;
55 break;
56 case Triple::ppc64:
57 PointerSize = 8;
58 Endianness = llvm::endianness::big;
59 break;
60 case Triple::ppc64le:
61 PointerSize = 8;
62 Endianness = llvm::endianness::little;
63 break;
64 default:
65 llvm_unreachable("Unrecognized architecture");
66 }
67
68 return std::make_unique<jitlink::LinkGraph>(
69 std::move(Name), MOP.getExecutionSession().getSymbolStringPool(), TT,
70 PointerSize, Endianness, jitlink::getGenericEdgeKindName);
71}
72
73// Creates a Bootstrap-Complete LinkGraph to run deferred actions.
74class ELFNixPlatformCompleteBootstrapMaterializationUnit
75 : public MaterializationUnit {
76public:
77 ELFNixPlatformCompleteBootstrapMaterializationUnit(
78 ELFNixPlatform &MOP, StringRef PlatformJDName,
79 SymbolStringPtr CompleteBootstrapSymbol, DeferredRuntimeFnMap DeferredAAs,
80 ExecutorAddr ELFNixHeaderAddr, ExecutorAddr PlatformBootstrap,
81 ExecutorAddr PlatformShutdown, ExecutorAddr RegisterJITDylib,
82 ExecutorAddr DeregisterJITDylib)
84 {{{CompleteBootstrapSymbol, JITSymbolFlags::None}}, nullptr}),
85 MOP(MOP), PlatformJDName(PlatformJDName),
86 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
87 DeferredAAsMap(std::move(DeferredAAs)),
88 ELFNixHeaderAddr(ELFNixHeaderAddr),
89 PlatformBootstrap(PlatformBootstrap),
90 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
91 DeregisterJITDylib(DeregisterJITDylib) {}
92
93 StringRef getName() const override {
94 return "ELFNixPlatformCompleteBootstrap";
95 }
96
97 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
98 using namespace jitlink;
99 auto G = createPlatformGraph(MOP, "<OrcRTCompleteBootstrap>");
100 auto &PlaceholderSection =
101 G->createSection("__orc_rt_cplt_bs", MemProt::Read);
102 auto &PlaceholderBlock =
103 G->createZeroFillBlock(PlaceholderSection, 1, ExecutorAddr(), 1, 0);
104 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
105 Linkage::Strong, Scope::Hidden, false, true);
106
107 // 1. Bootstrap the platform support code.
108 G->allocActions().push_back(
110 PlatformBootstrap, ELFNixHeaderAddr)),
111 cantFail(
112 WrapperFunctionCall::Create<SPSArgList<>>(PlatformShutdown))});
113
114 // 2. Register the platform JITDylib.
115 G->allocActions().push_back(
118 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
120 DeregisterJITDylib, ELFNixHeaderAddr))});
121
122 // 4. Add the deferred actions to the graph.
123 for (auto &[Fn, CallDatas] : DeferredAAsMap) {
124 for (auto &CallData : CallDatas) {
125 G->allocActions().push_back(
126 {WrapperFunctionCall(Fn.first->Addr, std::move(CallData.first)),
127 WrapperFunctionCall(Fn.second->Addr, std::move(CallData.second))});
128 }
129 }
130
131 MOP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
132 }
133
134 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
135
136private:
137 ELFNixPlatform &MOP;
138 StringRef PlatformJDName;
139 SymbolStringPtr CompleteBootstrapSymbol;
140 DeferredRuntimeFnMap DeferredAAsMap;
141 ExecutorAddr ELFNixHeaderAddr;
142 ExecutorAddr PlatformBootstrap;
143 ExecutorAddr PlatformShutdown;
144 ExecutorAddr RegisterJITDylib;
145 ExecutorAddr DeregisterJITDylib;
146};
147
148class DSOHandleMaterializationUnit : public MaterializationUnit {
149public:
150 DSOHandleMaterializationUnit(ELFNixPlatform &ENP,
151 const SymbolStringPtr &DSOHandleSymbol)
153 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
154 ENP(ENP) {}
155
156 StringRef getName() const override { return "DSOHandleMU"; }
157
158 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
159 unsigned PointerSize;
160 llvm::endianness Endianness;
161 jitlink::Edge::Kind EdgeKind;
162 const auto &TT = ENP.getExecutionSession().getTargetTriple();
163
164 switch (TT.getArch()) {
165 case Triple::x86_64:
166 PointerSize = 8;
167 Endianness = llvm::endianness::little;
169 break;
170 case Triple::aarch64:
171 PointerSize = 8;
172 Endianness = llvm::endianness::little;
174 break;
175 case Triple::ppc64:
176 PointerSize = 8;
177 Endianness = llvm::endianness::big;
178 EdgeKind = jitlink::ppc64::Pointer64;
179 break;
180 case Triple::ppc64le:
181 PointerSize = 8;
182 Endianness = llvm::endianness::little;
183 EdgeKind = jitlink::ppc64::Pointer64;
184 break;
185 default:
186 llvm_unreachable("Unrecognized architecture");
187 }
188
189 // void *__dso_handle = &__dso_handle;
190 auto G = std::make_unique<jitlink::LinkGraph>(
191 "<DSOHandleMU>", ENP.getExecutionSession().getSymbolStringPool(), TT,
192 PointerSize, Endianness, jitlink::getGenericEdgeKindName);
193 auto &DSOHandleSection =
194 G->createSection(".data.__dso_handle", MemProt::Read);
195 auto &DSOHandleBlock = G->createContentBlock(
196 DSOHandleSection, getDSOHandleContent(PointerSize), orc::ExecutorAddr(),
197 8, 0);
198 auto &DSOHandleSymbol = G->addDefinedSymbol(
199 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
200 jitlink::Linkage::Strong, jitlink::Scope::Default, false, true);
201 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
202
203 ENP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
204 }
205
206 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
207
208private:
210 createDSOHandleSectionInterface(ELFNixPlatform &ENP,
211 const SymbolStringPtr &DSOHandleSymbol) {
213 SymbolFlags[DSOHandleSymbol] = JITSymbolFlags::Exported;
214 return MaterializationUnit::Interface(std::move(SymbolFlags),
215 DSOHandleSymbol);
216 }
217
218 ArrayRef<char> getDSOHandleContent(size_t PointerSize) {
219 static const char Content[8] = {0};
220 assert(PointerSize <= sizeof Content);
221 return {Content, PointerSize};
222 }
223
224 ELFNixPlatform &ENP;
225};
226
227} // end anonymous namespace
228
229namespace llvm {
230namespace orc {
231
234 JITDylib &PlatformJD,
235 std::unique_ptr<DefinitionGenerator> OrcRuntime,
236 std::optional<SymbolAliasMap> RuntimeAliases) {
237
238 auto &ES = ObjLinkingLayer.getExecutionSession();
239
240 // If the target is not supported then bail out immediately.
241 if (!supportedTarget(ES.getTargetTriple()))
242 return make_error<StringError>("Unsupported ELFNixPlatform triple: " +
243 ES.getTargetTriple().str(),
245
246 auto &EPC = ES.getExecutorProcessControl();
247
248 // Create default aliases if the caller didn't supply any.
249 if (!RuntimeAliases) {
250 auto StandardRuntimeAliases = standardPlatformAliases(ES, PlatformJD);
251 if (!StandardRuntimeAliases)
252 return StandardRuntimeAliases.takeError();
253 RuntimeAliases = std::move(*StandardRuntimeAliases);
254 }
255
256 // Define the aliases.
257 if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
258 return std::move(Err);
259
260 // Add JIT-dispatch function support symbols.
261 if (auto Err = PlatformJD.define(
262 absoluteSymbols({{ES.intern("__orc_rt_jit_dispatch"),
263 {EPC.getJITDispatchInfo().JITDispatchFunction,
265 {ES.intern("__orc_rt_jit_dispatch_ctx"),
266 {EPC.getJITDispatchInfo().JITDispatchContext,
268 return std::move(Err);
269
270 // Create the instance.
271 Error Err = Error::success();
272 auto P = std::unique_ptr<ELFNixPlatform>(new ELFNixPlatform(
273 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
274 if (Err)
275 return std::move(Err);
276 return std::move(P);
277}
278
281 JITDylib &PlatformJD, const char *OrcRuntimePath,
282 std::optional<SymbolAliasMap> RuntimeAliases) {
283
284 // Create a generator for the ORC runtime archive.
285 auto OrcRuntimeArchiveGenerator =
286 StaticLibraryDefinitionGenerator::Load(ObjLinkingLayer, OrcRuntimePath);
287 if (!OrcRuntimeArchiveGenerator)
288 return OrcRuntimeArchiveGenerator.takeError();
289
290 return Create(ObjLinkingLayer, PlatformJD,
291 std::move(*OrcRuntimeArchiveGenerator),
292 std::move(RuntimeAliases));
293}
294
296 if (auto Err = JD.define(std::make_unique<DSOHandleMaterializationUnit>(
297 *this, DSOHandleSymbol)))
298 return Err;
299
300 return ES.lookup({&JD}, DSOHandleSymbol).takeError();
301}
302
304 std::lock_guard<std::mutex> Lock(PlatformMutex);
305 auto I = JITDylibToHandleAddr.find(&JD);
306 if (I != JITDylibToHandleAddr.end()) {
307 assert(HandleAddrToJITDylib.count(I->second) &&
308 "HandleAddrToJITDylib missing entry");
309 HandleAddrToJITDylib.erase(I->second);
310 JITDylibToHandleAddr.erase(I);
311 }
312 return Error::success();
313}
314
316 const MaterializationUnit &MU) {
317
318 auto &JD = RT.getJITDylib();
319 const auto &InitSym = MU.getInitializerSymbol();
320 if (!InitSym)
321 return Error::success();
322
323 RegisteredInitSymbols[&JD].add(InitSym,
325 LLVM_DEBUG({
326 dbgs() << "ELFNixPlatform: Registered init symbol " << *InitSym
327 << " for MU " << MU.getName() << "\n";
328 });
329 return Error::success();
330}
331
333 llvm_unreachable("Not supported yet");
334}
335
337 ArrayRef<std::pair<const char *, const char *>> AL) {
338 for (auto &KV : AL) {
339 auto AliasName = ES.intern(KV.first);
340 assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
341 Aliases[std::move(AliasName)] = {ES.intern(KV.second),
343 }
344}
345
348 JITDylib &PlatformJD) {
349 SymbolAliasMap Aliases;
350 addAliases(ES, Aliases, requiredCXXAliases());
353 return Aliases;
354}
355
358 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
359 {"__cxa_atexit", "__orc_rt_elfnix_cxa_atexit"},
360 {"atexit", "__orc_rt_elfnix_atexit"}};
361
362 return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
363}
364
367 static const std::pair<const char *, const char *>
368 StandardRuntimeUtilityAliases[] = {
369 {"__orc_rt_run_program", "__orc_rt_elfnix_run_program"},
370 {"__orc_rt_jit_dlerror", "__orc_rt_elfnix_jit_dlerror"},
371 {"__orc_rt_jit_dlopen", "__orc_rt_elfnix_jit_dlopen"},
372 {"__orc_rt_jit_dlupdate", "__orc_rt_elfnix_jit_dlupdate"},
373 {"__orc_rt_jit_dlclose", "__orc_rt_elfnix_jit_dlclose"},
374 {"__orc_rt_jit_dlsym", "__orc_rt_elfnix_jit_dlsym"},
375 {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
376
378 StandardRuntimeUtilityAliases);
379}
380
383 static const std::pair<const char *, const char *>
384 StandardLazyCompilationAliases[] = {
385 {"__orc_rt_reenter", "__orc_rt_sysv_reenter"}};
386
388 StandardLazyCompilationAliases);
389}
390
391bool ELFNixPlatform::supportedTarget(const Triple &TT) {
392 switch (TT.getArch()) {
393 case Triple::x86_64:
394 case Triple::aarch64:
395 // FIXME: jitlink for ppc64 hasn't been well tested, leave it unsupported
396 // right now.
397 case Triple::ppc64le:
398 return true;
399 default:
400 return false;
401 }
402}
403
404ELFNixPlatform::ELFNixPlatform(
405 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
406 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, Error &Err)
407 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
408 ObjLinkingLayer(ObjLinkingLayer),
409 DSOHandleSymbol(ES.intern("__dso_handle")) {
411 ObjLinkingLayer.addPlugin(std::make_unique<ELFNixPlatformPlugin>(*this));
412
413 PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
414
415 BootstrapInfo BI;
416 Bootstrap = &BI;
417
418 // PlatformJD hasn't been 'set-up' by the platform yet (since we're creating
419 // the platform now), so set it up.
420 if (auto E2 = setupJITDylib(PlatformJD)) {
421 Err = std::move(E2);
422 return;
423 }
424
425 // Step (2) Request runtime registration functions to trigger
426 // materialization..
427 if ((Err = ES.lookup(
428 makeJITDylibSearchOrder(&PlatformJD),
430 {PlatformBootstrap.Name, PlatformShutdown.Name,
431 RegisterJITDylib.Name, DeregisterJITDylib.Name,
432 RegisterInitSections.Name, DeregisterInitSections.Name,
433 RegisterObjectSections.Name,
434 DeregisterObjectSections.Name, CreatePThreadKey.Name}))
435 .takeError()))
436 return;
437
438 // Step (3) Wait for any incidental linker work to complete.
439 {
440 std::unique_lock<std::mutex> Lock(BI.Mutex);
441 BI.CV.wait(Lock, [&]() { return BI.ActiveGraphs == 0; });
442 Bootstrap = nullptr;
443 }
444
445 // Step (4) Add complete-bootstrap materialization unit and request.
446 auto BootstrapCompleteSymbol =
447 ES.intern("__orc_rt_elfnix_complete_bootstrap");
448 if ((Err = PlatformJD.define(
449 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
450 *this, PlatformJD.getName(), BootstrapCompleteSymbol,
451 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
452 PlatformBootstrap.Addr, PlatformShutdown.Addr,
453 RegisterJITDylib.Addr, DeregisterJITDylib.Addr))))
454 return;
455 if ((Err = ES.lookup(makeJITDylibSearchOrder(
457 std::move(BootstrapCompleteSymbol))
458 .takeError()))
459 return;
460
461 // Associate wrapper function tags with JIT-side function implementations.
462 if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
463 Err = std::move(E2);
464 return;
465 }
466}
467
468Error ELFNixPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
470
471 using RecordInitializersSPSSig =
473 WFs[ES.intern("__orc_rt_elfnix_push_initializers_tag")] =
474 ES.wrapAsyncWithSPS<RecordInitializersSPSSig>(
475 this, &ELFNixPlatform::rt_recordInitializers);
476
477 using LookupSymbolSPSSig =
479 WFs[ES.intern("__orc_rt_elfnix_symbol_lookup_tag")] =
480 ES.wrapAsyncWithSPS<LookupSymbolSPSSig>(this,
481 &ELFNixPlatform::rt_lookupSymbol);
482
483 return ES.registerJITDispatchHandlers(PlatformJD, std::move(WFs));
484}
485
486void ELFNixPlatform::pushInitializersLoop(
487 PushInitializersSendResultFn SendResult, JITDylibSP JD) {
490 SmallVector<JITDylib *, 16> Worklist({JD.get()});
491
492 ES.runSessionLocked([&]() {
493 while (!Worklist.empty()) {
494 // FIXME: Check for defunct dylibs.
495
496 auto DepJD = Worklist.back();
497 Worklist.pop_back();
498
499 // If we've already visited this JITDylib on this iteration then continue.
500 if (JDDepMap.count(DepJD))
501 continue;
502
503 // Add dep info.
504 auto &DM = JDDepMap[DepJD];
505 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
506 for (auto &KV : O) {
507 if (KV.first == DepJD)
508 continue;
509 DM.push_back(KV.first);
510 Worklist.push_back(KV.first);
511 }
512 });
513
514 // Add any registered init symbols.
515 auto RISItr = RegisteredInitSymbols.find(DepJD);
516 if (RISItr != RegisteredInitSymbols.end()) {
517 NewInitSymbols[DepJD] = std::move(RISItr->second);
518 RegisteredInitSymbols.erase(RISItr);
519 }
520 }
521 });
522
523 // If there are no further init symbols to look up then send the link order
524 // (as a list of header addresses) to the caller.
525 if (NewInitSymbols.empty()) {
526
527 // To make the list intelligible to the runtime we need to convert all
528 // JITDylib pointers to their header addresses. Only include JITDylibs
529 // that appear in the JITDylibToHandleAddr map (i.e. those that have been
530 // through setupJITDylib) -- bare JITDylibs aren't managed by the platform.
532 HeaderAddrs.reserve(JDDepMap.size());
533 {
534 std::lock_guard<std::mutex> Lock(PlatformMutex);
535 for (auto &KV : JDDepMap) {
536 auto I = JITDylibToHandleAddr.find(KV.first);
537 if (I != JITDylibToHandleAddr.end())
538 HeaderAddrs[KV.first] = I->second;
539 }
540 }
541
542 // Build the dep info map to return.
544 DIM.reserve(JDDepMap.size());
545 for (auto &KV : JDDepMap) {
546 auto HI = HeaderAddrs.find(KV.first);
547 // Skip unmanaged JITDylibs.
548 if (HI == HeaderAddrs.end())
549 continue;
550 auto H = HI->second;
551 ELFNixJITDylibDepInfo DepInfo;
552 for (auto &Dep : KV.second) {
553 auto HJ = HeaderAddrs.find(Dep);
554 if (HJ != HeaderAddrs.end())
555 DepInfo.push_back(HJ->second);
556 }
557 DIM.push_back(std::make_pair(H, std::move(DepInfo)));
558 }
559 SendResult(DIM);
560 return;
561 }
562
563 // Otherwise issue a lookup and re-run this phase when it completes.
564 lookupInitSymbolsAsync(
565 [this, SendResult = std::move(SendResult), JD](Error Err) mutable {
566 if (Err)
567 SendResult(std::move(Err));
568 else
569 pushInitializersLoop(std::move(SendResult), JD);
570 },
571 ES, std::move(NewInitSymbols));
572}
573
574void ELFNixPlatform::rt_recordInitializers(
575 PushInitializersSendResultFn SendResult, ExecutorAddr JDHeaderAddr) {
576 JITDylibSP JD;
577 {
578 std::lock_guard<std::mutex> Lock(PlatformMutex);
579 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
580 if (I != HandleAddrToJITDylib.end())
581 JD = I->second;
582 }
583
584 LLVM_DEBUG({
585 dbgs() << "ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr << ") ";
586 if (JD)
587 dbgs() << "pushing initializers for " << JD->getName() << "\n";
588 else
589 dbgs() << "No JITDylib for header address.\n";
590 });
591
592 if (!JD) {
593 SendResult(make_error<StringError>("No JITDylib with header addr " +
594 formatv("{0:x}", JDHeaderAddr),
596 return;
597 }
598
599 pushInitializersLoop(std::move(SendResult), JD);
600}
601
602void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
603 ExecutorAddr Handle,
604 StringRef SymbolName) {
605 LLVM_DEBUG({
606 dbgs() << "ELFNixPlatform::rt_lookupSymbol(\"" << Handle << "\")\n";
607 });
608
609 JITDylib *JD = nullptr;
610
611 {
612 std::lock_guard<std::mutex> Lock(PlatformMutex);
613 auto I = HandleAddrToJITDylib.find(Handle);
614 if (I != HandleAddrToJITDylib.end())
615 JD = I->second;
616 }
617
618 if (!JD) {
619 LLVM_DEBUG(dbgs() << " No JITDylib for handle " << Handle << "\n");
620 SendResult(make_error<StringError>("No JITDylib associated with handle " +
621 formatv("{0:x}", Handle),
623 return;
624 }
625
626 // Use functor class to work around XL build compiler issue on AIX.
627 class RtLookupNotifyComplete {
628 public:
629 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
630 : SendResult(std::move(SendResult)) {}
631 void operator()(Expected<SymbolMap> Result) {
632 if (Result) {
633 assert(Result->size() == 1 && "Unexpected result map count");
634 SendResult(Result->begin()->second.getAddress());
635 } else {
636 SendResult(Result.takeError());
637 }
638 }
639
640 private:
641 SendSymbolAddressFn SendResult;
642 };
643
644 ES.lookup(
645 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
646 SymbolLookupSet(ES.intern(SymbolName)), SymbolState::Ready,
647 RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
648}
649
650Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
652 // Increment the active graphs count in BootstrapInfo.
653 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
654 ++MP.Bootstrap.load()->ActiveGraphs;
655 return Error::success();
656}
657
658Error ELFNixPlatform::ELFNixPlatformPlugin::
659 bootstrapPipelineRecordRuntimeFunctions(jitlink::LinkGraph &G) {
660 // Record bootstrap function names.
661 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
662 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
663 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
664 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
665 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
666 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
667 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
668 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
669 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
670 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
671 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
672
673 bool RegisterELFNixHeader = false;
674
675 for (auto *Sym : G.defined_symbols()) {
676 for (auto &RTSym : RuntimeSymbols) {
677 if (Sym->hasName() && *Sym->getName() == RTSym.first) {
678 if (*RTSym.second)
679 return make_error<StringError>(
680 "Duplicate " + RTSym.first +
681 " detected during ELFNixPlatform bootstrap",
683
684 if (*Sym->getName() == *MP.DSOHandleSymbol)
685 RegisterELFNixHeader = true;
686
687 *RTSym.second = Sym->getAddress();
688 }
689 }
690 }
691
692 if (RegisterELFNixHeader) {
693 // If this graph defines the elfnix header symbol then create the internal
694 // mapping between it and PlatformJD.
695 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
696 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
697 MP.Bootstrap.load()->ELFNixHeaderAddr;
698 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
699 &MP.PlatformJD;
700 }
701
702 return Error::success();
703}
704
705Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
707 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
708 assert(MP.Bootstrap && "DeferredAAs reset before bootstrap completed");
709 --MP.Bootstrap.load()->ActiveGraphs;
710 // Notify Bootstrap->CV while holding the mutex because the mutex is
711 // also keeping Bootstrap->CV alive.
712 if (MP.Bootstrap.load()->ActiveGraphs == 0)
713 MP.Bootstrap.load()->CV.notify_all();
714 return Error::success();
715}
716
717Error ELFNixPlatform::registerPerObjectSections(
719 bool IsBootstrapping) {
720 using SPSRegisterPerObjSectionsArgs =
722
723 if (LLVM_UNLIKELY(IsBootstrapping)) {
724 Bootstrap.load()->addArgumentsToRTFnMap(
725 &RegisterObjectSections, &DeregisterObjectSections,
726 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
727 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
728 return Error::success();
729 }
730
731 G.allocActions().push_back(
732 {cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
733 RegisterObjectSections.Addr, POSR)),
734 cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
735 DeregisterObjectSections.Addr, POSR))});
736
737 return Error::success();
738}
739
740Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
741 if (!CreatePThreadKey.Addr)
742 return make_error<StringError>(
743 "Attempting to create pthread key in target, but runtime support has "
744 "not been loaded yet",
746
748 if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
749 CreatePThreadKey.Addr, Result))
750 return std::move(Err);
751 return Result;
752}
753
754void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
757 using namespace jitlink;
758
759 bool InBootstrapPhase =
760 &MR.getTargetJITDylib() == &MP.PlatformJD && MP.Bootstrap;
761
762 // If we're in the bootstrap phase then increment the active graphs.
763 if (InBootstrapPhase) {
764 Config.PrePrunePasses.push_back(
765 [this](LinkGraph &G) { return bootstrapPipelineStart(G); });
766 Config.PostAllocationPasses.push_back([this](LinkGraph &G) {
767 return bootstrapPipelineRecordRuntimeFunctions(G);
768 });
769 }
770
771 // If the initializer symbol is the __dso_handle symbol then just add
772 // the DSO handle support passes.
773 if (auto InitSymbol = MR.getInitializerSymbol()) {
774 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
775 addDSOHandleSupportPasses(MR, Config);
776 // The DSOHandle materialization unit doesn't require any other
777 // support, so we can bail out early.
778 return;
779 }
780
781 /// Preserve init sections.
782 Config.PrePrunePasses.push_back(
783 [this, &MR](jitlink::LinkGraph &G) -> Error {
784 if (auto Err = preserveInitSections(G, MR))
785 return Err;
786 return Error::success();
787 });
788 }
789
790 // Add passes for eh-frame and TLV support.
791 addEHAndTLVSupportPasses(MR, Config, InBootstrapPhase);
792
793 // If the object contains initializers then add passes to record them.
794 Config.PostFixupPasses.push_back([this, &JD = MR.getTargetJITDylib(),
795 InBootstrapPhase](jitlink::LinkGraph &G) {
796 return registerInitSections(G, JD, InBootstrapPhase);
797 });
798
799 // If we're in the bootstrap phase then steal allocation actions and then
800 // decrement the active graphs.
801 if (InBootstrapPhase)
802 Config.PostFixupPasses.push_back(
803 [this](LinkGraph &G) { return bootstrapPipelineEnd(G); });
804}
805
806void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
808
809 Config.PostAllocationPasses.push_back([this, &JD = MR.getTargetJITDylib()](
811 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
812 return Sym->getName() == MP.DSOHandleSymbol;
813 });
814 assert(I != G.defined_symbols().end() && "Missing DSO handle symbol");
815 {
816 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
817 auto HandleAddr = (*I)->getAddress();
818 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
819 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
820
821 G.allocActions().push_back(
824 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
826 MP.DeregisterJITDylib.Addr, HandleAddr))});
827 }
828 return Error::success();
829 });
830}
831
832void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
834 bool IsBootstrapping) {
835
836 // Insert TLV lowering at the start of the PostPrunePasses, since we want
837 // it to run before GOT/PLT lowering.
838
839 // TODO: Check that before the fixTLVSectionsAndEdges pass, the GOT/PLT build
840 // pass has done. Because the TLS descriptor need to be allocate in GOT.
841 Config.PostPrunePasses.push_back(
842 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
843 return fixTLVSectionsAndEdges(G, JD);
844 });
845
846 // Add a pass to register the final addresses of the eh-frame and TLV sections
847 // with the runtime.
848 Config.PostFixupPasses.push_back([this, IsBootstrapping](
851
852 if (auto *EHFrameSection = G.findSectionByName(ELFEHFrameSectionName)) {
853 jitlink::SectionRange R(*EHFrameSection);
854 if (!R.empty())
855 POSR.EHFrameSection = R.getRange();
856 }
857
858 // Get a pointer to the thread data section if there is one. It will be used
859 // below.
860 jitlink::Section *ThreadDataSection =
861 G.findSectionByName(ELFThreadDataSectionName);
862
863 // Handle thread BSS section if there is one.
864 if (auto *ThreadBSSSection = G.findSectionByName(ELFThreadBSSSectionName)) {
865 // If there's already a thread data section in this graph then merge the
866 // thread BSS section content into it, otherwise just treat the thread
867 // BSS section as the thread data section.
868 if (ThreadDataSection)
869 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
870 else
871 ThreadDataSection = ThreadBSSSection;
872 }
873
874 // Having merged thread BSS (if present) and thread data (if present),
875 // record the resulting section range.
876 if (ThreadDataSection) {
877 jitlink::SectionRange R(*ThreadDataSection);
878 if (!R.empty())
879 POSR.ThreadDataSection = R.getRange();
880 }
881
882 if (POSR.EHFrameSection.Start || POSR.ThreadDataSection.Start) {
883 if (auto Err = MP.registerPerObjectSections(G, POSR, IsBootstrapping))
884 return Err;
885 }
886
887 return Error::success();
888 });
889}
890
891Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
893
894 if (const auto &InitSymName = MR.getInitializerSymbol()) {
895
896 jitlink::Symbol *InitSym = nullptr;
897
898 for (auto &InitSection : G.sections()) {
899 // Skip non-init sections.
900 if (!isELFInitializerSection(InitSection.getName()) ||
901 InitSection.empty())
902 continue;
903
904 // Create the init symbol if it has not been created already and attach it
905 // to the first block.
906 if (!InitSym) {
907 auto &B = **InitSection.blocks().begin();
908 InitSym = &G.addDefinedSymbol(
909 B, 0, *InitSymName, B.getSize(), jitlink::Linkage::Strong,
910 jitlink::Scope::SideEffectsOnly, false, true);
911 }
912
913 // Add keep-alive edges to anonymous symbols in all other init blocks.
914 for (auto *B : InitSection.blocks()) {
915 if (B == &InitSym->getBlock())
916 continue;
917
918 auto &S = G.addAnonymousSymbol(*B, 0, B->getSize(), false, true);
919 InitSym->getBlock().addEdge(jitlink::Edge::KeepAlive, 0, S, 0);
920 }
921 }
922 }
923
924 return Error::success();
925}
926
927Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
928 jitlink::LinkGraph &G, JITDylib &JD, bool IsBootstrapping) {
929 SmallVector<ExecutorAddrRange> ELFNixPlatformSecs;
930 LLVM_DEBUG(dbgs() << "ELFNixPlatform::registerInitSections\n");
931
932 SmallVector<jitlink::Section *> OrderedInitSections;
933 for (auto &Sec : G.sections())
934 if (isELFInitializerSection(Sec.getName()))
935 OrderedInitSections.push_back(&Sec);
936
937 // FIXME: This handles priority order within the current graph, but we'll need
938 // to include priority information in the initializer allocation
939 // actions in order to respect the ordering across multiple graphs.
940 llvm::sort(OrderedInitSections, [](const jitlink::Section *LHS,
941 const jitlink::Section *RHS) {
942 if (LHS->getName().starts_with(".init_array")) {
943 if (RHS->getName().starts_with(".init_array")) {
944 StringRef LHSPrioStr(LHS->getName());
945 StringRef RHSPrioStr(RHS->getName());
946 uint64_t LHSPriority;
947 bool LHSHasPriority = LHSPrioStr.consume_front(".init_array.") &&
948 !LHSPrioStr.getAsInteger(10, LHSPriority);
949 uint64_t RHSPriority;
950 bool RHSHasPriority = RHSPrioStr.consume_front(".init_array.") &&
951 !RHSPrioStr.getAsInteger(10, RHSPriority);
952 if (LHSHasPriority)
953 return RHSHasPriority ? LHSPriority < RHSPriority : true;
954 else if (RHSHasPriority)
955 return false;
956 // If we get here we'll fall through to the
957 // LHS->getName() < RHS->getName() test below.
958 } else {
959 // .init_array[.N] comes before any non-.init_array[.N] section.
960 return true;
961 }
962 }
963 return LHS->getName() < RHS->getName();
964 });
965
966 for (auto &Sec : OrderedInitSections)
967 ELFNixPlatformSecs.push_back(jitlink::SectionRange(*Sec).getRange());
968
969 // Dump the scraped inits.
970 LLVM_DEBUG({
971 dbgs() << "ELFNixPlatform: Scraped " << G.getName() << " init sections:\n";
972 for (auto &Sec : G.sections()) {
974 dbgs() << " " << Sec.getName() << ": " << R.getRange() << "\n";
975 }
976 });
977
978 ExecutorAddr HeaderAddr;
979 {
980 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
981 auto I = MP.JITDylibToHandleAddr.find(&JD);
982 assert(I != MP.JITDylibToHandleAddr.end() && "No header registered for JD");
983 assert(I->second && "Null header registered for JD");
984 HeaderAddr = I->second;
985 }
986
987 using SPSRegisterInitSectionsArgs =
989
990 if (LLVM_UNLIKELY(IsBootstrapping)) {
991 MP.Bootstrap.load()->addArgumentsToRTFnMap(
992 &MP.RegisterInitSections, &MP.DeregisterInitSections,
993 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
994 ELFNixPlatformSecs),
995 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
996 ELFNixPlatformSecs));
997 return Error::success();
998 }
999
1000 G.allocActions().push_back(
1001 {cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
1002 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
1003 cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
1004 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
1005
1006 return Error::success();
1007}
1008
1009Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
1011 auto TLSGetAddrSymbolName = G.intern("__tls_get_addr");
1012 auto TLSDescResolveSymbolName = G.intern("__tlsdesc_resolver");
1013 for (auto *Sym : G.external_symbols()) {
1014 if (Sym->getName() == TLSGetAddrSymbolName) {
1015 auto TLSGetAddr =
1016 MP.getExecutionSession().intern("___orc_rt_elfnix_tls_get_addr");
1017 Sym->setName(std::move(TLSGetAddr));
1018 } else if (Sym->getName() == TLSDescResolveSymbolName) {
1019 auto TLSGetAddr =
1020 MP.getExecutionSession().intern("___orc_rt_elfnix_tlsdesc_resolver");
1021 Sym->setName(std::move(TLSGetAddr));
1022 }
1023 }
1024
1025 auto *TLSInfoEntrySection = G.findSectionByName("$__TLSINFO");
1026
1027 if (TLSInfoEntrySection) {
1028 std::optional<uint64_t> Key;
1029 {
1030 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1031 auto I = MP.JITDylibToPThreadKey.find(&JD);
1032 if (I != MP.JITDylibToPThreadKey.end())
1033 Key = I->second;
1034 }
1035 if (!Key) {
1036 if (auto KeyOrErr = MP.createPThreadKey())
1037 Key = *KeyOrErr;
1038 else
1039 return KeyOrErr.takeError();
1040 }
1041
1042 uint64_t PlatformKeyBits =
1043 support::endian::byte_swap(*Key, G.getEndianness());
1044
1045 for (auto *B : TLSInfoEntrySection->blocks()) {
1046 // FIXME: The TLS descriptor byte length may different with different
1047 // ISA
1048 assert(B->getSize() == (G.getPointerSize() * 2) &&
1049 "TLS descriptor must be 2 words length");
1050 auto TLSInfoEntryContent = B->getMutableContent(G);
1051 memcpy(TLSInfoEntryContent.data(), &PlatformKeyBits, G.getPointerSize());
1052 }
1053 }
1054
1055 return Error::success();
1056}
1057
1058} // End namespace orc.
1059} // End namespace llvm.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
Definition: Compiler.h:320
#define LLVM_DEBUG(...)
Definition: Debug.h:106
T Content
std::string Name
RelaxConfig Config
Definition: ELF_riscv.cpp:506
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define _
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
#define H(x, y, z)
Definition: MD5.cpp:57
#define P(N)
if(PassOpts->AAPipeline)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:156
unsigned size() const
Definition: DenseMap.h:99
bool empty() const
Definition: DenseMap.h:98
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:152
iterator end()
Definition: DenseMap.h:84
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
Definition: DenseMap.h:103
Helper for Errors used as out-parameters.
Definition: Error.h:1130
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Tagged union holding either a T or a Error.
Definition: Error.h:481
bool empty() const
Definition: SmallVector.h:81
size_t size() const
Definition: SmallVector.h:78
void resize(size_type N)
Definition: SmallVector.h:638
void push_back(const T &Elt)
Definition: SmallVector.h:413
pointer data()
Return a pointer to the vector's buffer, even if empty().
Definition: SmallVector.h:286
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:265
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
const std::string & str() const
Definition: Triple.h:450
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
Mediates between ELFNix initialization and ExecutionSession state.
ObjectLinkingLayer & getObjectLinkingLayer() const
static Expected< SymbolAliasMap > standardPlatformAliases(ExecutionSession &ES, JITDylib &PlatformJD)
Returns an AliasMap containing the default aliases for the ELFNixPlatform.
Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU) override
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
Error notifyRemoving(ResourceTracker &RT) override
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
Error setupJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
ExecutionSession & getExecutionSession() const
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases()
Returns the array of standard runtime utility aliases for ELF.
static Expected< std::unique_ptr< ELFNixPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.
static ArrayRef< std::pair< const char *, const char * > > standardLazyCompilationAliases()
Returns a list of aliases required to enable lazy compilation via the ORC runtime.
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases()
Returns the array of required CXX aliases.
Error teardownJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
An ExecutionSession represents a running JIT program.
Definition: Core.h:1339
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1379
const Triple & getTargetTriple() const
Return the triple for the executor.
Definition: Core.h:1382
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition: Core.h:1393
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
Definition: Core.h:1607
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
Definition: Core.h:1388
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Definition: Core.cpp:1788
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
Definition: Core.cpp:1897
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition: Core.h:1403
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition: Core.h:897
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Definition: Core.h:1822
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition: Core.h:1805
ExecutionSession & getExecutionSession()
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:571
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition: Core.h:610
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition: Core.h:596
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
virtual StringRef getName() const =0
Return the name of this materialization unit.
virtual void materialize(std::unique_ptr< MaterializationResponsibility > R)=0
Implementations of this method should materialize all symbols in the materialzation unit,...
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
An ObjectLayer implementation built on JITLink.
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
API to remove / transfer ownership of JIT resources.
Definition: Core.h:77
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition: Core.h:92
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:194
Pointer to a pooled string representing a symbol name.
A utility class for serializing to a blob from a variadic list.
SPS tag type for expecteds, which are either a T or a string representing an error.
Output char buffer with overflow check.
Represents a serialized wrapper function call.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Key
PAL metadata keys.
StringRef ELFThreadBSSSectionName
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
Definition: Core.h:177
std::vector< std::pair< ExecutorAddr, ELFNixJITDylibDepInfo > > ELFNixJITDylibDepInfoMap
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition: Core.h:745
std::vector< ExecutorAddr > ELFNixJITDylibDepInfo
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
StringRef ELFEHFrameSectionName
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
StringRef ELFThreadDataSectionName
std::unordered_map< std::pair< RuntimeFunction *, RuntimeFunction * >, SmallVector< std::pair< shared::WrapperFunctionCall::ArgDataBufferType, shared::WrapperFunctionCall::ArgDataBufferType > >, FunctionPairKeyHash, FunctionPairKeyEqual > DeferredRuntimeFnMap
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition: Core.cpp:38
bool isELFInitializerSection(StringRef SecName)
value_type byte_swap(value_type value, endianness endian)
Definition: Endian.h:44
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1664
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:756
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
endianness
Definition: bit.h:70
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858