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 auto &ES = MOP.getExecutionSession();
44 return std::make_unique<jitlink::LinkGraph>(
45 std::move(Name), ES.getSymbolStringPool(), ES.getTargetTriple(),
47}
48
49// Creates a Bootstrap-Complete LinkGraph to run deferred actions.
50class ELFNixPlatformCompleteBootstrapMaterializationUnit
51 : public MaterializationUnit {
52public:
53 ELFNixPlatformCompleteBootstrapMaterializationUnit(
54 ELFNixPlatform &MOP, StringRef PlatformJDName,
55 SymbolStringPtr CompleteBootstrapSymbol, DeferredRuntimeFnMap DeferredAAs,
56 ExecutorAddr ELFNixHeaderAddr, ExecutorAddr PlatformBootstrap,
57 ExecutorAddr PlatformShutdown, ExecutorAddr RegisterJITDylib,
58 ExecutorAddr DeregisterJITDylib)
60 {{{CompleteBootstrapSymbol, JITSymbolFlags::None}}, nullptr}),
61 MOP(MOP), PlatformJDName(PlatformJDName),
62 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
63 DeferredAAsMap(std::move(DeferredAAs)),
64 ELFNixHeaderAddr(ELFNixHeaderAddr),
65 PlatformBootstrap(PlatformBootstrap),
66 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
67 DeregisterJITDylib(DeregisterJITDylib) {}
68
69 StringRef getName() const override {
70 return "ELFNixPlatformCompleteBootstrap";
71 }
72
73 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
74 using namespace jitlink;
75 auto G = createPlatformGraph(MOP, "<OrcRTCompleteBootstrap>");
76 auto &PlaceholderSection =
77 G->createSection("__orc_rt_cplt_bs", MemProt::Read);
78 auto &PlaceholderBlock =
79 G->createZeroFillBlock(PlaceholderSection, 1, ExecutorAddr(), 1, 0);
80 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
81 Linkage::Strong, Scope::Hidden, false, true);
82
83 // 1. Bootstrap the platform support code.
84 G->allocActions().push_back(
86 PlatformBootstrap, ELFNixHeaderAddr)),
88 WrapperFunctionCall::Create<SPSArgList<>>(PlatformShutdown))});
89
90 // 2. Register the platform JITDylib.
91 G->allocActions().push_back(
94 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
96 DeregisterJITDylib, ELFNixHeaderAddr))});
97
98 // 4. Add the deferred actions to the graph.
99 for (auto &[Fn, CallDatas] : DeferredAAsMap) {
100 for (auto &CallData : CallDatas) {
101 G->allocActions().push_back(
102 {WrapperFunctionCall(Fn.first->Addr, std::move(CallData.first)),
103 WrapperFunctionCall(Fn.second->Addr, std::move(CallData.second))});
104 }
105 }
106
107 MOP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
108 }
109
110 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
111
112private:
113 ELFNixPlatform &MOP;
114 StringRef PlatformJDName;
115 SymbolStringPtr CompleteBootstrapSymbol;
116 DeferredRuntimeFnMap DeferredAAsMap;
117 ExecutorAddr ELFNixHeaderAddr;
118 ExecutorAddr PlatformBootstrap;
119 ExecutorAddr PlatformShutdown;
120 ExecutorAddr RegisterJITDylib;
121 ExecutorAddr DeregisterJITDylib;
122};
123
124class DSOHandleMaterializationUnit : public MaterializationUnit {
125public:
126 DSOHandleMaterializationUnit(ELFNixPlatform &ENP,
127 const SymbolStringPtr &DSOHandleSymbol)
129 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
130 ENP(ENP) {}
131
132 StringRef getName() const override { return "DSOHandleMU"; }
133
134 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
135
136 auto &ES = ENP.getExecutionSession();
137
138 jitlink::Edge::Kind EdgeKind;
139
140 switch (ES.getTargetTriple().getArch()) {
141 case Triple::x86_64:
143 break;
144 case Triple::aarch64:
146 break;
147 case Triple::ppc64:
148 EdgeKind = jitlink::ppc64::Pointer64;
149 break;
150 case Triple::ppc64le:
151 EdgeKind = jitlink::ppc64::Pointer64;
152 break;
153 default:
154 llvm_unreachable("Unrecognized architecture");
155 }
156
157 // void *__dso_handle = &__dso_handle;
158 auto G = std::make_unique<jitlink::LinkGraph>(
159 "<DSOHandleMU>", ES.getSymbolStringPool(), ES.getTargetTriple(),
161 auto &DSOHandleSection =
162 G->createSection(".data.__dso_handle", MemProt::Read);
163 auto &DSOHandleBlock = G->createContentBlock(
164 DSOHandleSection, getDSOHandleContent(G->getPointerSize()),
165 orc::ExecutorAddr(), 8, 0);
166 auto &DSOHandleSymbol = G->addDefinedSymbol(
167 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
168 jitlink::Linkage::Strong, jitlink::Scope::Default, false, true);
169 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
170
171 ENP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
172 }
173
174 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
175
176private:
178 createDSOHandleSectionInterface(ELFNixPlatform &ENP,
179 const SymbolStringPtr &DSOHandleSymbol) {
181 SymbolFlags[DSOHandleSymbol] = JITSymbolFlags::Exported;
182 return MaterializationUnit::Interface(std::move(SymbolFlags),
183 DSOHandleSymbol);
184 }
185
186 ArrayRef<char> getDSOHandleContent(size_t PointerSize) {
187 static const char Content[8] = {0};
188 assert(PointerSize <= sizeof Content);
189 return {Content, PointerSize};
190 }
191
192 ELFNixPlatform &ENP;
193};
194
195} // end anonymous namespace
196
197namespace llvm {
198namespace orc {
199
202 JITDylib &PlatformJD,
203 std::unique_ptr<DefinitionGenerator> OrcRuntime,
204 std::optional<SymbolAliasMap> RuntimeAliases) {
205
206 auto &ES = ObjLinkingLayer.getExecutionSession();
207
208 // If the target is not supported then bail out immediately.
209 if (!supportedTarget(ES.getTargetTriple()))
210 return make_error<StringError>("Unsupported ELFNixPlatform triple: " +
211 ES.getTargetTriple().str(),
213
214 auto &EPC = ES.getExecutorProcessControl();
215
216 // Create default aliases if the caller didn't supply any.
217 if (!RuntimeAliases) {
218 auto StandardRuntimeAliases = standardPlatformAliases(ES, PlatformJD);
219 if (!StandardRuntimeAliases)
220 return StandardRuntimeAliases.takeError();
221 RuntimeAliases = std::move(*StandardRuntimeAliases);
222 }
223
224 // Define the aliases.
225 if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
226 return std::move(Err);
227
228 // Add JIT-dispatch function support symbols.
229 if (auto Err = PlatformJD.define(
230 absoluteSymbols({{ES.intern("__orc_rt_jit_dispatch"),
231 {EPC.getJITDispatchInfo().JITDispatchFunction,
233 {ES.intern("__orc_rt_jit_dispatch_ctx"),
234 {EPC.getJITDispatchInfo().JITDispatchContext,
236 return std::move(Err);
237
238 // Create the instance.
239 Error Err = Error::success();
240 auto P = std::unique_ptr<ELFNixPlatform>(new ELFNixPlatform(
241 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
242 if (Err)
243 return std::move(Err);
244 return std::move(P);
245}
246
249 JITDylib &PlatformJD, const char *OrcRuntimePath,
250 std::optional<SymbolAliasMap> RuntimeAliases) {
251
252 // Create a generator for the ORC runtime archive.
253 auto OrcRuntimeArchiveGenerator =
254 StaticLibraryDefinitionGenerator::Load(ObjLinkingLayer, OrcRuntimePath);
255 if (!OrcRuntimeArchiveGenerator)
256 return OrcRuntimeArchiveGenerator.takeError();
257
258 return Create(ObjLinkingLayer, PlatformJD,
259 std::move(*OrcRuntimeArchiveGenerator),
260 std::move(RuntimeAliases));
261}
262
264 if (auto Err = JD.define(std::make_unique<DSOHandleMaterializationUnit>(
265 *this, DSOHandleSymbol)))
266 return Err;
267
268 return ES.lookup({&JD}, DSOHandleSymbol).takeError();
269}
270
272 std::lock_guard<std::mutex> Lock(PlatformMutex);
273 auto I = JITDylibToHandleAddr.find(&JD);
274 if (I != JITDylibToHandleAddr.end()) {
275 assert(HandleAddrToJITDylib.count(I->second) &&
276 "HandleAddrToJITDylib missing entry");
277 HandleAddrToJITDylib.erase(I->second);
278 JITDylibToHandleAddr.erase(I);
279 }
280 return Error::success();
281}
282
284 const MaterializationUnit &MU) {
285
286 auto &JD = RT.getJITDylib();
287 const auto &InitSym = MU.getInitializerSymbol();
288 if (!InitSym)
289 return Error::success();
290
291 RegisteredInitSymbols[&JD].add(InitSym,
293 LLVM_DEBUG({
294 dbgs() << "ELFNixPlatform: Registered init symbol " << *InitSym
295 << " for MU " << MU.getName() << "\n";
296 });
297 return Error::success();
298}
299
301 llvm_unreachable("Not supported yet");
302}
303
305 ArrayRef<std::pair<const char *, const char *>> AL) {
306 for (auto &KV : AL) {
307 auto AliasName = ES.intern(KV.first);
308 assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
309 Aliases[std::move(AliasName)] = {ES.intern(KV.second),
311 }
312}
313
316 JITDylib &PlatformJD) {
317 SymbolAliasMap Aliases;
318 addAliases(ES, Aliases, requiredCXXAliases());
321 return Aliases;
322}
323
326 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
327 {"__cxa_atexit", "__orc_rt_elfnix_cxa_atexit"},
328 {"atexit", "__orc_rt_elfnix_atexit"}};
329
330 return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
331}
332
335 static const std::pair<const char *, const char *>
336 StandardRuntimeUtilityAliases[] = {
337 {"__orc_rt_run_program", "__orc_rt_elfnix_run_program"},
338 {"__orc_rt_jit_dlerror", "__orc_rt_elfnix_jit_dlerror"},
339 {"__orc_rt_jit_dlopen", "__orc_rt_elfnix_jit_dlopen"},
340 {"__orc_rt_jit_dlupdate", "__orc_rt_elfnix_jit_dlupdate"},
341 {"__orc_rt_jit_dlclose", "__orc_rt_elfnix_jit_dlclose"},
342 {"__orc_rt_jit_dlsym", "__orc_rt_elfnix_jit_dlsym"},
343 {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
344
346 StandardRuntimeUtilityAliases);
347}
348
351 static const std::pair<const char *, const char *>
352 StandardLazyCompilationAliases[] = {
353 {"__orc_rt_reenter", "__orc_rt_sysv_reenter"}};
354
356 StandardLazyCompilationAliases);
357}
358
359bool ELFNixPlatform::supportedTarget(const Triple &TT) {
360 switch (TT.getArch()) {
361 case Triple::x86_64:
362 case Triple::aarch64:
363 // FIXME: jitlink for ppc64 hasn't been well tested, leave it unsupported
364 // right now.
365 case Triple::ppc64le:
366 return true;
367 default:
368 return false;
369 }
370}
371
372ELFNixPlatform::ELFNixPlatform(
373 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
374 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, Error &Err)
375 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
376 ObjLinkingLayer(ObjLinkingLayer),
377 DSOHandleSymbol(ES.intern("__dso_handle")) {
379 ObjLinkingLayer.addPlugin(std::make_unique<ELFNixPlatformPlugin>(*this));
380
381 PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
382
383 BootstrapInfo BI;
384 Bootstrap = &BI;
385
386 // PlatformJD hasn't been 'set-up' by the platform yet (since we're creating
387 // the platform now), so set it up.
388 if (auto E2 = setupJITDylib(PlatformJD)) {
389 Err = std::move(E2);
390 return;
391 }
392
393 // Step (2) Request runtime registration functions to trigger
394 // materialization..
395 if ((Err = ES.lookup(
396 makeJITDylibSearchOrder(&PlatformJD),
398 {PlatformBootstrap.Name, PlatformShutdown.Name,
399 RegisterJITDylib.Name, DeregisterJITDylib.Name,
400 RegisterInitSections.Name, DeregisterInitSections.Name,
401 RegisterObjectSections.Name,
402 DeregisterObjectSections.Name, CreatePThreadKey.Name}))
403 .takeError()))
404 return;
405
406 // Step (3) Wait for any incidental linker work to complete.
407 {
408 std::unique_lock<std::mutex> Lock(BI.Mutex);
409 BI.CV.wait(Lock, [&]() { return BI.ActiveGraphs == 0; });
410 Bootstrap = nullptr;
411 }
412
413 // Step (4) Add complete-bootstrap materialization unit and request.
414 auto BootstrapCompleteSymbol =
415 ES.intern("__orc_rt_elfnix_complete_bootstrap");
416 if ((Err = PlatformJD.define(
417 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
418 *this, PlatformJD.getName(), BootstrapCompleteSymbol,
419 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
420 PlatformBootstrap.Addr, PlatformShutdown.Addr,
421 RegisterJITDylib.Addr, DeregisterJITDylib.Addr))))
422 return;
423 if ((Err = ES.lookup(makeJITDylibSearchOrder(
425 std::move(BootstrapCompleteSymbol))
426 .takeError()))
427 return;
428
429 // Associate wrapper function tags with JIT-side function implementations.
430 if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
431 Err = std::move(E2);
432 return;
433 }
434}
435
436Error ELFNixPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
438
439 using RecordInitializersSPSSig =
441 WFs[ES.intern("__orc_rt_elfnix_push_initializers_tag")] =
442 ES.wrapAsyncWithSPS<RecordInitializersSPSSig>(
443 this, &ELFNixPlatform::rt_recordInitializers);
444
445 using LookupSymbolSPSSig =
447 WFs[ES.intern("__orc_rt_elfnix_symbol_lookup_tag")] =
448 ES.wrapAsyncWithSPS<LookupSymbolSPSSig>(this,
449 &ELFNixPlatform::rt_lookupSymbol);
450
451 return ES.registerJITDispatchHandlers(PlatformJD, std::move(WFs));
452}
453
454void ELFNixPlatform::pushInitializersLoop(
455 PushInitializersSendResultFn SendResult, JITDylibSP JD) {
458 SmallVector<JITDylib *, 16> Worklist({JD.get()});
459
460 ES.runSessionLocked([&]() {
461 while (!Worklist.empty()) {
462 // FIXME: Check for defunct dylibs.
463
464 auto DepJD = Worklist.back();
465 Worklist.pop_back();
466
467 // If we've already visited this JITDylib on this iteration then continue.
468 if (JDDepMap.count(DepJD))
469 continue;
470
471 // Add dep info.
472 auto &DM = JDDepMap[DepJD];
473 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
474 for (auto &KV : O) {
475 if (KV.first == DepJD)
476 continue;
477 DM.push_back(KV.first);
478 Worklist.push_back(KV.first);
479 }
480 });
481
482 // Add any registered init symbols.
483 auto RISItr = RegisteredInitSymbols.find(DepJD);
484 if (RISItr != RegisteredInitSymbols.end()) {
485 NewInitSymbols[DepJD] = std::move(RISItr->second);
486 RegisteredInitSymbols.erase(RISItr);
487 }
488 }
489 });
490
491 // If there are no further init symbols to look up then send the link order
492 // (as a list of header addresses) to the caller.
493 if (NewInitSymbols.empty()) {
494
495 // To make the list intelligible to the runtime we need to convert all
496 // JITDylib pointers to their header addresses. Only include JITDylibs
497 // that appear in the JITDylibToHandleAddr map (i.e. those that have been
498 // through setupJITDylib) -- bare JITDylibs aren't managed by the platform.
500 HeaderAddrs.reserve(JDDepMap.size());
501 {
502 std::lock_guard<std::mutex> Lock(PlatformMutex);
503 for (auto &KV : JDDepMap) {
504 auto I = JITDylibToHandleAddr.find(KV.first);
505 if (I != JITDylibToHandleAddr.end())
506 HeaderAddrs[KV.first] = I->second;
507 }
508 }
509
510 // Build the dep info map to return.
512 DIM.reserve(JDDepMap.size());
513 for (auto &KV : JDDepMap) {
514 auto HI = HeaderAddrs.find(KV.first);
515 // Skip unmanaged JITDylibs.
516 if (HI == HeaderAddrs.end())
517 continue;
518 auto H = HI->second;
519 ELFNixJITDylibDepInfo DepInfo;
520 for (auto &Dep : KV.second) {
521 auto HJ = HeaderAddrs.find(Dep);
522 if (HJ != HeaderAddrs.end())
523 DepInfo.push_back(HJ->second);
524 }
525 DIM.push_back(std::make_pair(H, std::move(DepInfo)));
526 }
527 SendResult(DIM);
528 return;
529 }
530
531 // Otherwise issue a lookup and re-run this phase when it completes.
532 lookupInitSymbolsAsync(
533 [this, SendResult = std::move(SendResult), JD](Error Err) mutable {
534 if (Err)
535 SendResult(std::move(Err));
536 else
537 pushInitializersLoop(std::move(SendResult), JD);
538 },
539 ES, std::move(NewInitSymbols));
540}
541
542void ELFNixPlatform::rt_recordInitializers(
543 PushInitializersSendResultFn SendResult, ExecutorAddr JDHeaderAddr) {
544 JITDylibSP JD;
545 {
546 std::lock_guard<std::mutex> Lock(PlatformMutex);
547 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
548 if (I != HandleAddrToJITDylib.end())
549 JD = I->second;
550 }
551
552 LLVM_DEBUG({
553 dbgs() << "ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr << ") ";
554 if (JD)
555 dbgs() << "pushing initializers for " << JD->getName() << "\n";
556 else
557 dbgs() << "No JITDylib for header address.\n";
558 });
559
560 if (!JD) {
561 SendResult(make_error<StringError>("No JITDylib with header addr " +
562 formatv("{0:x}", JDHeaderAddr),
564 return;
565 }
566
567 pushInitializersLoop(std::move(SendResult), JD);
568}
569
570void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
571 ExecutorAddr Handle,
572 StringRef SymbolName) {
573 LLVM_DEBUG({
574 dbgs() << "ELFNixPlatform::rt_lookupSymbol(\"" << Handle << "\")\n";
575 });
576
577 JITDylib *JD = nullptr;
578
579 {
580 std::lock_guard<std::mutex> Lock(PlatformMutex);
581 auto I = HandleAddrToJITDylib.find(Handle);
582 if (I != HandleAddrToJITDylib.end())
583 JD = I->second;
584 }
585
586 if (!JD) {
587 LLVM_DEBUG(dbgs() << " No JITDylib for handle " << Handle << "\n");
588 SendResult(make_error<StringError>("No JITDylib associated with handle " +
589 formatv("{0:x}", Handle),
591 return;
592 }
593
594 // Use functor class to work around XL build compiler issue on AIX.
595 class RtLookupNotifyComplete {
596 public:
597 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
598 : SendResult(std::move(SendResult)) {}
599 void operator()(Expected<SymbolMap> Result) {
600 if (Result) {
601 assert(Result->size() == 1 && "Unexpected result map count");
602 SendResult(Result->begin()->second.getAddress());
603 } else {
604 SendResult(Result.takeError());
605 }
606 }
607
608 private:
609 SendSymbolAddressFn SendResult;
610 };
611
612 ES.lookup(
613 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
614 SymbolLookupSet(ES.intern(SymbolName)), SymbolState::Ready,
615 RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
616}
617
618Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
620 // Increment the active graphs count in BootstrapInfo.
621 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
622 ++MP.Bootstrap.load()->ActiveGraphs;
623 return Error::success();
624}
625
626Error ELFNixPlatform::ELFNixPlatformPlugin::
627 bootstrapPipelineRecordRuntimeFunctions(jitlink::LinkGraph &G) {
628 // Record bootstrap function names.
629 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
630 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
631 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
632 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
633 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
634 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
635 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
636 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
637 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
638 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
639 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
640
641 bool RegisterELFNixHeader = false;
642
643 for (auto *Sym : G.defined_symbols()) {
644 for (auto &RTSym : RuntimeSymbols) {
645 if (Sym->hasName() && *Sym->getName() == RTSym.first) {
646 if (*RTSym.second)
647 return make_error<StringError>(
648 "Duplicate " + RTSym.first +
649 " detected during ELFNixPlatform bootstrap",
651
652 if (*Sym->getName() == *MP.DSOHandleSymbol)
653 RegisterELFNixHeader = true;
654
655 *RTSym.second = Sym->getAddress();
656 }
657 }
658 }
659
660 if (RegisterELFNixHeader) {
661 // If this graph defines the elfnix header symbol then create the internal
662 // mapping between it and PlatformJD.
663 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
664 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
665 MP.Bootstrap.load()->ELFNixHeaderAddr;
666 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
667 &MP.PlatformJD;
668 }
669
670 return Error::success();
671}
672
673Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
675 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
676 assert(MP.Bootstrap && "DeferredAAs reset before bootstrap completed");
677 --MP.Bootstrap.load()->ActiveGraphs;
678 // Notify Bootstrap->CV while holding the mutex because the mutex is
679 // also keeping Bootstrap->CV alive.
680 if (MP.Bootstrap.load()->ActiveGraphs == 0)
681 MP.Bootstrap.load()->CV.notify_all();
682 return Error::success();
683}
684
685Error ELFNixPlatform::registerPerObjectSections(
687 bool IsBootstrapping) {
688 using SPSRegisterPerObjSectionsArgs =
690
691 if (LLVM_UNLIKELY(IsBootstrapping)) {
692 Bootstrap.load()->addArgumentsToRTFnMap(
693 &RegisterObjectSections, &DeregisterObjectSections,
694 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
695 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
696 return Error::success();
697 }
698
699 G.allocActions().push_back(
700 {cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
701 RegisterObjectSections.Addr, POSR)),
702 cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
703 DeregisterObjectSections.Addr, POSR))});
704
705 return Error::success();
706}
707
708Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
709 if (!CreatePThreadKey.Addr)
710 return make_error<StringError>(
711 "Attempting to create pthread key in target, but runtime support has "
712 "not been loaded yet",
714
716 if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
717 CreatePThreadKey.Addr, Result))
718 return std::move(Err);
719 return Result;
720}
721
722void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
725 using namespace jitlink;
726
727 bool InBootstrapPhase =
728 &MR.getTargetJITDylib() == &MP.PlatformJD && MP.Bootstrap;
729
730 // If we're in the bootstrap phase then increment the active graphs.
731 if (InBootstrapPhase) {
732 Config.PrePrunePasses.push_back(
733 [this](LinkGraph &G) { return bootstrapPipelineStart(G); });
734 Config.PostAllocationPasses.push_back([this](LinkGraph &G) {
735 return bootstrapPipelineRecordRuntimeFunctions(G);
736 });
737 }
738
739 // If the initializer symbol is the __dso_handle symbol then just add
740 // the DSO handle support passes.
741 if (auto InitSymbol = MR.getInitializerSymbol()) {
742 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
743 addDSOHandleSupportPasses(MR, Config);
744 // The DSOHandle materialization unit doesn't require any other
745 // support, so we can bail out early.
746 return;
747 }
748
749 /// Preserve init sections.
750 Config.PrePrunePasses.push_back(
751 [this, &MR](jitlink::LinkGraph &G) -> Error {
752 if (auto Err = preserveInitSections(G, MR))
753 return Err;
754 return Error::success();
755 });
756 }
757
758 // Add passes for eh-frame and TLV support.
759 addEHAndTLVSupportPasses(MR, Config, InBootstrapPhase);
760
761 // If the object contains initializers then add passes to record them.
762 Config.PostFixupPasses.push_back([this, &JD = MR.getTargetJITDylib(),
763 InBootstrapPhase](jitlink::LinkGraph &G) {
764 return registerInitSections(G, JD, InBootstrapPhase);
765 });
766
767 // If we're in the bootstrap phase then steal allocation actions and then
768 // decrement the active graphs.
769 if (InBootstrapPhase)
770 Config.PostFixupPasses.push_back(
771 [this](LinkGraph &G) { return bootstrapPipelineEnd(G); });
772}
773
774void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
776
777 Config.PostAllocationPasses.push_back([this, &JD = MR.getTargetJITDylib()](
779 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
780 return Sym->getName() == MP.DSOHandleSymbol;
781 });
782 assert(I != G.defined_symbols().end() && "Missing DSO handle symbol");
783 {
784 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
785 auto HandleAddr = (*I)->getAddress();
786 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
787 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
788
789 G.allocActions().push_back(
792 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
794 MP.DeregisterJITDylib.Addr, HandleAddr))});
795 }
796 return Error::success();
797 });
798}
799
800void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
802 bool IsBootstrapping) {
803
804 // Insert TLV lowering at the start of the PostPrunePasses, since we want
805 // it to run before GOT/PLT lowering.
806
807 // TODO: Check that before the fixTLVSectionsAndEdges pass, the GOT/PLT build
808 // pass has done. Because the TLS descriptor need to be allocate in GOT.
809 Config.PostPrunePasses.push_back(
810 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
811 return fixTLVSectionsAndEdges(G, JD);
812 });
813
814 // Add a pass to register the final addresses of the eh-frame and TLV sections
815 // with the runtime.
816 Config.PostFixupPasses.push_back([this, IsBootstrapping](
819
820 if (auto *EHFrameSection = G.findSectionByName(ELFEHFrameSectionName)) {
821 jitlink::SectionRange R(*EHFrameSection);
822 if (!R.empty())
823 POSR.EHFrameSection = R.getRange();
824 }
825
826 // Get a pointer to the thread data section if there is one. It will be used
827 // below.
828 jitlink::Section *ThreadDataSection =
829 G.findSectionByName(ELFThreadDataSectionName);
830
831 // Handle thread BSS section if there is one.
832 if (auto *ThreadBSSSection = G.findSectionByName(ELFThreadBSSSectionName)) {
833 // If there's already a thread data section in this graph then merge the
834 // thread BSS section content into it, otherwise just treat the thread
835 // BSS section as the thread data section.
836 if (ThreadDataSection)
837 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
838 else
839 ThreadDataSection = ThreadBSSSection;
840 }
841
842 // Having merged thread BSS (if present) and thread data (if present),
843 // record the resulting section range.
844 if (ThreadDataSection) {
845 jitlink::SectionRange R(*ThreadDataSection);
846 if (!R.empty())
847 POSR.ThreadDataSection = R.getRange();
848 }
849
850 if (POSR.EHFrameSection.Start || POSR.ThreadDataSection.Start) {
851 if (auto Err = MP.registerPerObjectSections(G, POSR, IsBootstrapping))
852 return Err;
853 }
854
855 return Error::success();
856 });
857}
858
859Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
861
862 if (const auto &InitSymName = MR.getInitializerSymbol()) {
863
864 jitlink::Symbol *InitSym = nullptr;
865
866 for (auto &InitSection : G.sections()) {
867 // Skip non-init sections.
868 if (!isELFInitializerSection(InitSection.getName()) ||
869 InitSection.empty())
870 continue;
871
872 // Create the init symbol if it has not been created already and attach it
873 // to the first block.
874 if (!InitSym) {
875 auto &B = **InitSection.blocks().begin();
876 InitSym = &G.addDefinedSymbol(
877 B, 0, *InitSymName, B.getSize(), jitlink::Linkage::Strong,
878 jitlink::Scope::SideEffectsOnly, false, true);
879 }
880
881 // Add keep-alive edges to anonymous symbols in all other init blocks.
882 for (auto *B : InitSection.blocks()) {
883 if (B == &InitSym->getBlock())
884 continue;
885
886 auto &S = G.addAnonymousSymbol(*B, 0, B->getSize(), false, true);
887 InitSym->getBlock().addEdge(jitlink::Edge::KeepAlive, 0, S, 0);
888 }
889 }
890 }
891
892 return Error::success();
893}
894
895Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
896 jitlink::LinkGraph &G, JITDylib &JD, bool IsBootstrapping) {
897 SmallVector<ExecutorAddrRange> ELFNixPlatformSecs;
898 LLVM_DEBUG(dbgs() << "ELFNixPlatform::registerInitSections\n");
899
900 SmallVector<jitlink::Section *> OrderedInitSections;
901 for (auto &Sec : G.sections())
902 if (isELFInitializerSection(Sec.getName()))
903 OrderedInitSections.push_back(&Sec);
904
905 // FIXME: This handles priority order within the current graph, but we'll need
906 // to include priority information in the initializer allocation
907 // actions in order to respect the ordering across multiple graphs.
908 llvm::sort(OrderedInitSections, [](const jitlink::Section *LHS,
909 const jitlink::Section *RHS) {
910 if (LHS->getName().starts_with(".init_array")) {
911 if (RHS->getName().starts_with(".init_array")) {
912 StringRef LHSPrioStr(LHS->getName());
913 StringRef RHSPrioStr(RHS->getName());
914 uint64_t LHSPriority;
915 bool LHSHasPriority = LHSPrioStr.consume_front(".init_array.") &&
916 !LHSPrioStr.getAsInteger(10, LHSPriority);
917 uint64_t RHSPriority;
918 bool RHSHasPriority = RHSPrioStr.consume_front(".init_array.") &&
919 !RHSPrioStr.getAsInteger(10, RHSPriority);
920 if (LHSHasPriority)
921 return RHSHasPriority ? LHSPriority < RHSPriority : true;
922 else if (RHSHasPriority)
923 return false;
924 // If we get here we'll fall through to the
925 // LHS->getName() < RHS->getName() test below.
926 } else {
927 // .init_array[.N] comes before any non-.init_array[.N] section.
928 return true;
929 }
930 }
931 return LHS->getName() < RHS->getName();
932 });
933
934 for (auto &Sec : OrderedInitSections)
935 ELFNixPlatformSecs.push_back(jitlink::SectionRange(*Sec).getRange());
936
937 // Dump the scraped inits.
938 LLVM_DEBUG({
939 dbgs() << "ELFNixPlatform: Scraped " << G.getName() << " init sections:\n";
940 for (auto &Sec : G.sections()) {
942 dbgs() << " " << Sec.getName() << ": " << R.getRange() << "\n";
943 }
944 });
945
946 ExecutorAddr HeaderAddr;
947 {
948 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
949 auto I = MP.JITDylibToHandleAddr.find(&JD);
950 assert(I != MP.JITDylibToHandleAddr.end() && "No header registered for JD");
951 assert(I->second && "Null header registered for JD");
952 HeaderAddr = I->second;
953 }
954
955 using SPSRegisterInitSectionsArgs =
957
958 if (LLVM_UNLIKELY(IsBootstrapping)) {
959 MP.Bootstrap.load()->addArgumentsToRTFnMap(
960 &MP.RegisterInitSections, &MP.DeregisterInitSections,
961 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
962 ELFNixPlatformSecs),
963 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
964 ELFNixPlatformSecs));
965 return Error::success();
966 }
967
968 G.allocActions().push_back(
969 {cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
970 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
971 cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
972 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
973
974 return Error::success();
975}
976
977Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
979 auto TLSGetAddrSymbolName = G.intern("__tls_get_addr");
980 auto TLSDescResolveSymbolName = G.intern("__tlsdesc_resolver");
981 for (auto *Sym : G.external_symbols()) {
982 if (Sym->getName() == TLSGetAddrSymbolName) {
983 auto TLSGetAddr =
984 MP.getExecutionSession().intern("___orc_rt_elfnix_tls_get_addr");
985 Sym->setName(std::move(TLSGetAddr));
986 } else if (Sym->getName() == TLSDescResolveSymbolName) {
987 auto TLSGetAddr =
988 MP.getExecutionSession().intern("___orc_rt_elfnix_tlsdesc_resolver");
989 Sym->setName(std::move(TLSGetAddr));
990 }
991 }
992
993 auto *TLSInfoEntrySection = G.findSectionByName("$__TLSINFO");
994
995 if (TLSInfoEntrySection) {
996 std::optional<uint64_t> Key;
997 {
998 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
999 auto I = MP.JITDylibToPThreadKey.find(&JD);
1000 if (I != MP.JITDylibToPThreadKey.end())
1001 Key = I->second;
1002 }
1003 if (!Key) {
1004 if (auto KeyOrErr = MP.createPThreadKey())
1005 Key = *KeyOrErr;
1006 else
1007 return KeyOrErr.takeError();
1008 }
1009
1010 uint64_t PlatformKeyBits =
1011 support::endian::byte_swap(*Key, G.getEndianness());
1012
1013 for (auto *B : TLSInfoEntrySection->blocks()) {
1014 // FIXME: The TLS descriptor byte length may different with different
1015 // ISA
1016 assert(B->getSize() == (G.getPointerSize() * 2) &&
1017 "TLS descriptor must be 2 words length");
1018 auto TLSInfoEntryContent = B->getMutableContent(G);
1019 memcpy(TLSInfoEntryContent.data(), &PlatformKeyBits, G.getPointerSize());
1020 }
1021 }
1022
1023 return Error::success();
1024}
1025
1026} // End namespace orc.
1027} // 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
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
const std::string & str() const
Definition: Triple.h:462
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:1340
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1380
const Triple & getTargetTriple() const
Return the triple for the executor.
Definition: Core.h:1383
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition: Core.h:1394
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:1608
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:1798
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
Definition: Core.cpp:1893
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition: Core.h:1404
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:1823
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition: Core.h:1806
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
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858