LLVM 24.0.0git
COFFPlatform.cpp
Go to the documentation of this file.
1//===------- COFFPlatform.cpp - Utilities for executing COFF in Orc -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
21#include "llvm/Object/COFF.h"
22
24
25#define DEBUG_TYPE "orc"
26
27using namespace llvm;
28using namespace llvm::orc;
29using namespace llvm::orc::shared;
30
31namespace llvm {
32namespace orc {
33namespace shared {
34
44
45} // namespace shared
46} // namespace orc
47} // namespace llvm
48// Controller-interface descriptors for the COFF platform runtime's
49// bootstrap-time SPS wrapper calls. Kept in the .cpp (the COFF platform's
50// private contract with its runtime; the SPS arg types live here too), and in
51// a named namespace so the constexpr Name members -- read only as constants by
52// ProxySpec -- don't trip -Wunused-const-variable.
55 static constexpr SymbolNameSpec Name =
56 SymbolNameSpec::c("__orc_rt_coff_platform_bootstrap");
57 using SPSSig = void();
58};
60 static constexpr SymbolNameSpec Name =
61 SymbolNameSpec::c("__orc_rt_coff_register_jitdylib");
63};
65 static constexpr SymbolNameSpec Name =
66 SymbolNameSpec::c("__orc_rt_coff_register_object_sections");
68};
69} // namespace llvm::orc::coff_sps_ci
70
71namespace {
72
73class COFFHeaderMaterializationUnit : public MaterializationUnit {
74public:
75 COFFHeaderMaterializationUnit(COFFPlatform &CP,
76 const SymbolStringPtr &HeaderStartSymbol)
77 : MaterializationUnit(createHeaderInterface(CP, HeaderStartSymbol)),
78 CP(CP) {}
79
80 StringRef getName() const override { return "COFFHeaderMU"; }
81
82 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
83 auto G = std::make_unique<jitlink::LinkGraph>(
84 "<COFFHeaderMU>", CP.getExecutionSession().getSymbolStringPool(),
85 CP.getExecutionSession().getTargetTriple(),
86 CP.getExecutionSession().getTargetTriple().getArchPointerBitWidth() / 8,
88 auto &HeaderSection = G->createSection("__header", MemProt::Read);
89 auto &HeaderBlock = createHeaderBlock(*G, HeaderSection);
90
91 // Init symbol is __ImageBase symbol.
92 auto &ImageBaseSymbol = G->addDefinedSymbol(
93 HeaderBlock, 0, *R->getInitializerSymbol(), HeaderBlock.getSize(),
95
96 addImageBaseRelocationEdge(HeaderBlock, ImageBaseSymbol);
97
98 CP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
99 }
100
101 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
102
103private:
104 struct HeaderSymbol {
105 const char *Name;
106 uint64_t Offset;
107 };
108
109 struct NTHeader {
110 support::ulittle32_t PEMagic;
111 object::coff_file_header FileHeader;
112 struct PEHeader {
113 object::pe32plus_header Header;
114 object::data_directory DataDirectory[COFF::NUM_DATA_DIRECTORIES + 1];
115 } OptionalHeader;
116 };
117
118 struct HeaderBlockContent {
119 object::dos_header DOSHeader;
120 COFFHeaderMaterializationUnit::NTHeader NTHeader;
121 };
122
123 static jitlink::Block &createHeaderBlock(jitlink::LinkGraph &G,
124 jitlink::Section &HeaderSection) {
125 HeaderBlockContent Hdr = {};
126
127 // Set up magic
128 Hdr.DOSHeader.Magic[0] = 'M';
129 Hdr.DOSHeader.Magic[1] = 'Z';
130 Hdr.DOSHeader.AddressOfNewExeHeader =
131 offsetof(HeaderBlockContent, NTHeader);
132 uint32_t PEMagic = *reinterpret_cast<const uint32_t *>(COFF::PEMagic);
133 Hdr.NTHeader.PEMagic = PEMagic;
134 Hdr.NTHeader.OptionalHeader.Header.Magic = COFF::PE32Header::PE32_PLUS;
135
136 switch (G.getTargetTriple().getArch()) {
137 case Triple::x86_64:
138 Hdr.NTHeader.FileHeader.Machine = COFF::IMAGE_FILE_MACHINE_AMD64;
139 break;
140 default:
141 llvm_unreachable("Unrecognized architecture");
142 }
143
144 auto HeaderContent = G.allocateContent(
145 ArrayRef<char>(reinterpret_cast<const char *>(&Hdr), sizeof(Hdr)));
146
147 return G.createContentBlock(HeaderSection, HeaderContent, ExecutorAddr(), 8,
148 0);
149 }
150
151 static void addImageBaseRelocationEdge(jitlink::Block &B,
152 jitlink::Symbol &ImageBase) {
153 auto ImageBaseOffset = offsetof(HeaderBlockContent, NTHeader) +
154 offsetof(NTHeader, OptionalHeader) +
155 offsetof(object::pe32plus_header, ImageBase);
156 B.addEdge(jitlink::x86_64::Pointer64, ImageBaseOffset, ImageBase, 0);
157 }
158
159 static MaterializationUnit::Interface
160 createHeaderInterface(COFFPlatform &MOP,
161 const SymbolStringPtr &HeaderStartSymbol) {
162 SymbolFlagsMap HeaderSymbolFlags;
163
164 HeaderSymbolFlags[HeaderStartSymbol] = JITSymbolFlags::Exported;
165
166 return MaterializationUnit::Interface(std::move(HeaderSymbolFlags),
167 HeaderStartSymbol);
168 }
169
170 COFFPlatform &CP;
171};
172
173} // end anonymous namespace
174
175namespace llvm {
176namespace orc {
177
178Expected<std::unique_ptr<COFFPlatform>>
180 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
181 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
182 const char *VCRuntimePath,
183 std::optional<SymbolAliasMap> RuntimeAliases) {
184
185 auto &ES = ObjLinkingLayer.getExecutionSession();
186
187 // If the target is not supported then bail out immediately.
188 if (!supportedTarget(ES.getTargetTriple()))
189 return make_error<StringError>("Unsupported COFFPlatform triple: " +
190 ES.getTargetTriple().str(),
192
193 auto GeneratorArchive =
194 object::Archive::create(OrcRuntimeArchiveBuffer->getMemBufferRef());
195 if (!GeneratorArchive)
196 return GeneratorArchive.takeError();
197
198 std::set<std::string> DylibsToPreload;
199 auto OrcRuntimeArchiveGenerator = StaticLibraryDefinitionGenerator::Create(
200 ObjLinkingLayer, nullptr, std::move(*GeneratorArchive),
201 COFFImportFileScanner(DylibsToPreload));
202 if (!OrcRuntimeArchiveGenerator)
203 return OrcRuntimeArchiveGenerator.takeError();
204
205 // We need a second instance of the archive (for now) for the Platform. We
206 // can `cantFail` this call, since if it were going to fail it would have
207 // failed above.
208 auto RuntimeArchive = cantFail(
209 object::Archive::create(OrcRuntimeArchiveBuffer->getMemBufferRef()));
210
211 // Create default aliases if the caller didn't supply any.
212 if (!RuntimeAliases)
213 RuntimeAliases = standardPlatformAliases(ES);
214
215 // Define the aliases.
216 if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
217 return std::move(Err);
218
219 {
220 // Add JIT dispatch reexports from bootstrap JITDylib.
221 MangleAndInterner Mangle(ES);
222 auto Exports = buildSimpleReexportsAliasMap(
223 ES.getBootstrapJITDylib(),
224 {{Mangle(rt::DispatchName), Mangle(rt::DispatchCtxName)}});
225 if (!Exports)
226 return Exports.takeError();
227 if (auto Err =
228 PlatformJD.define(reexports(ES.getBootstrapJITDylib(), *Exports)))
229 return Err;
230 }
231
232 // Create the instance.
233 Error Err = Error::success();
234 auto P = std::unique_ptr<COFFPlatform>(new COFFPlatform(
235 ObjLinkingLayer, PlatformJD, std::move(*OrcRuntimeArchiveGenerator),
236 std::move(DylibsToPreload), std::move(OrcRuntimeArchiveBuffer),
237 std::move(RuntimeArchive), std::move(LoadDynLibrary), StaticVCRuntime,
238 VCRuntimePath, Err));
239 if (Err)
240 return std::move(Err);
241 return std::move(P);
242}
243
246 const char *OrcRuntimePath,
247 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
248 const char *VCRuntimePath,
249 std::optional<SymbolAliasMap> RuntimeAliases) {
250
251 auto ArchiveBuffer = MemoryBuffer::getFile(OrcRuntimePath);
252 if (!ArchiveBuffer)
253 return createFileError(OrcRuntimePath, ArchiveBuffer.getError());
254
255 return Create(ObjLinkingLayer, PlatformJD, std::move(*ArchiveBuffer),
256 std::move(LoadDynLibrary), StaticVCRuntime, VCRuntimePath,
257 std::move(RuntimeAliases));
258}
259
260Expected<MemoryBufferRef> COFFPlatform::getPerJDObjectFile() {
261 auto PerJDObj = OrcRuntimeArchive->findSym("__orc_rt_coff_per_jd_marker");
262 if (!PerJDObj)
263 return PerJDObj.takeError();
264
265 if (!*PerJDObj)
266 return make_error<StringError>("Could not find per jd object file",
268
269 auto Buffer = (*PerJDObj)->getAsBinary();
270 if (!Buffer)
271 return Buffer.takeError();
272
273 return (*Buffer)->getMemoryBufferRef();
274}
275
277 ArrayRef<std::pair<const char *, const char *>> AL) {
278 for (auto &KV : AL) {
279 auto AliasName = ES.intern(KV.first);
280 assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
281 Aliases[std::move(AliasName)] = {ES.intern(KV.second),
283 }
284}
285
287 if (auto Err = JD.define(std::make_unique<COFFHeaderMaterializationUnit>(
288 *this, COFFHeaderStartSymbol)))
289 return Err;
290
291 if (auto Err = ES.lookup({&JD}, COFFHeaderStartSymbol).takeError())
292 return Err;
293
294 // Define the CXX aliases.
295 SymbolAliasMap CXXAliases;
296 addAliases(ES, CXXAliases, requiredCXXAliases());
297 if (auto Err = JD.define(symbolAliases(std::move(CXXAliases))))
298 return Err;
299
300 auto PerJDObj = getPerJDObjectFile();
301 if (!PerJDObj)
302 return PerJDObj.takeError();
303
304 auto I = getObjectFileInterface(ES, *PerJDObj);
305 if (!I)
306 return I.takeError();
307
308 if (auto Err = ObjLinkingLayer.add(
309 JD, MemoryBuffer::getMemBuffer(*PerJDObj, false), std::move(*I)))
310 return Err;
311
312 if (!Bootstrapping) {
313 auto ImportedLibs = StaticVCRuntime
314 ? VCRuntimeBootstrap->loadStaticVCRuntime(JD)
315 : VCRuntimeBootstrap->loadDynamicVCRuntime(JD);
316 if (!ImportedLibs)
317 return ImportedLibs.takeError();
318 for (auto &Lib : *ImportedLibs)
319 if (auto Err = LoadDynLibrary(JD, Lib))
320 return Err;
321 if (StaticVCRuntime)
322 if (auto Err = VCRuntimeBootstrap->initializeStaticVCRuntime(JD))
323 return Err;
324 }
325
326 JD.addGenerator(DLLImportDefinitionGenerator::Create(ES, ObjLinkingLayer));
327 return Error::success();
328}
329
331 std::lock_guard<std::mutex> Lock(PlatformMutex);
332 auto I = JITDylibToHeaderAddr.find(&JD);
333 if (I != JITDylibToHeaderAddr.end()) {
334 assert(HeaderAddrToJITDylib.count(I->second) &&
335 "HeaderAddrToJITDylib missing entry");
336 HeaderAddrToJITDylib.erase(I->second);
337 JITDylibToHeaderAddr.erase(I);
338 }
339 return Error::success();
340}
341
343 const MaterializationUnit &MU) {
344 auto &JD = RT.getJITDylib();
345 const auto &InitSym = MU.getInitializerSymbol();
346 if (!InitSym)
347 return Error::success();
348
349 RegisteredInitSymbols[&JD].add(InitSym,
351
352 LLVM_DEBUG({
353 dbgs() << "COFFPlatform: Registered init symbol " << *InitSym << " for MU "
354 << MU.getName() << "\n";
355 });
356 return Error::success();
357}
358
362
368
371 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
372 {"_CxxThrowException", "__orc_rt_coff_cxx_throw_exception"},
373 {"_onexit", "__orc_rt_coff_onexit_per_jd"},
374 {"atexit", "__orc_rt_coff_atexit_per_jd"}};
375
376 return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
377}
378
381 static const std::pair<const char *, const char *>
382 StandardRuntimeUtilityAliases[] = {
383 {"__orc_rt_run_program", "__orc_rt_coff_run_program"},
384 {"__orc_rt_jit_dlerror", "__orc_rt_coff_jit_dlerror"},
385 {"__orc_rt_jit_dlopen", "__orc_rt_coff_jit_dlopen"},
386 {"__orc_rt_jit_dlupdate", "__orc_rt_coff_jit_dlupdate"},
387 {"__orc_rt_jit_dlclose", "__orc_rt_coff_jit_dlclose"},
388 {"__orc_rt_jit_dlsym", "__orc_rt_coff_jit_dlsym"},
389 {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
390
392 StandardRuntimeUtilityAliases);
393}
394
395bool COFFPlatform::supportedTarget(const Triple &TT) {
396 switch (TT.getArch()) {
397 case Triple::x86_64:
398 return true;
399 default:
400 return false;
401 }
402}
403
404COFFPlatform::COFFPlatform(
405 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
406 std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
407 std::set<std::string> DylibsToPreload,
408 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
409 std::unique_ptr<object::Archive> OrcRuntimeArchive,
410 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
411 const char *VCRuntimePath, Error &Err)
412 : ES(ObjLinkingLayer.getExecutionSession()),
413 ObjLinkingLayer(ObjLinkingLayer),
414 LoadDynLibrary(std::move(LoadDynLibrary)),
415 OrcRuntimeArchiveBuffer(std::move(OrcRuntimeArchiveBuffer)),
416 OrcRuntimeArchive(std::move(OrcRuntimeArchive)),
417 StaticVCRuntime(StaticVCRuntime),
418 COFFHeaderStartSymbol(ES.intern("__ImageBase")) {
420
421 Bootstrapping.store(true);
422 ObjLinkingLayer.addPlugin(std::make_unique<COFFPlatformPlugin>(*this));
423
424 // Load vc runtime
425 auto VCRT =
426 COFFVCRuntimeBootstrapper::Create(ES, ObjLinkingLayer, VCRuntimePath);
427 if (!VCRT) {
428 Err = VCRT.takeError();
429 return;
430 }
431 VCRuntimeBootstrap = std::move(*VCRT);
432
433 auto ImportedLibs =
434 StaticVCRuntime ? VCRuntimeBootstrap->loadStaticVCRuntime(PlatformJD)
435 : VCRuntimeBootstrap->loadDynamicVCRuntime(PlatformJD);
436 if (!ImportedLibs) {
437 Err = ImportedLibs.takeError();
438 return;
439 }
440
441 for (auto &Lib : *ImportedLibs)
442 DylibsToPreload.insert(Lib);
443
444 PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
445
446 // PlatformJD hasn't been set up by the platform yet (since we're creating
447 // the platform now), so set it up.
448 if (auto E2 = setupJITDylib(PlatformJD)) {
449 Err = std::move(E2);
450 return;
451 }
452
453 for (auto& Lib : DylibsToPreload)
454 if (auto E2 = this->LoadDynLibrary(PlatformJD, Lib)) {
455 Err = std::move(E2);
456 return;
457 }
458
459 if (StaticVCRuntime)
460 if (auto E2 = VCRuntimeBootstrap->initializeStaticVCRuntime(PlatformJD)) {
461 Err = std::move(E2);
462 return;
463 }
464
465 // Associate wrapper function tags with JIT-side function implementations.
466 if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
467 Err = std::move(E2);
468 return;
469 }
470
471 // Lookup addresses of runtime functions callable by the platform,
472 // call the platform bootstrap function to initialize the platform-state
473 // object in the executor.
474 if (auto E2 = bootstrapCOFFRuntime(PlatformJD)) {
475 Err = std::move(E2);
476 return;
477 }
478
479 Bootstrapping.store(false);
480 JDBootstrapStates.clear();
481}
482
483Expected<COFFPlatform::JITDylibDepMap>
484COFFPlatform::buildJDDepMap(JITDylib &JD) {
485 return ES.runSessionLocked([&]() -> Expected<JITDylibDepMap> {
486 JITDylibDepMap JDDepMap;
487
488 SmallVector<JITDylib *, 16> Worklist({&JD});
489 while (!Worklist.empty()) {
490 auto CurJD = Worklist.back();
491 Worklist.pop_back();
492
493 auto &DM = JDDepMap[CurJD];
494 CurJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
495 DM.reserve(O.size());
496 for (auto &KV : O) {
497 if (KV.first == CurJD)
498 continue;
499 {
500 // Bare jitdylibs not known to the platform
501 std::lock_guard<std::mutex> Lock(PlatformMutex);
502 if (!JITDylibToHeaderAddr.count(KV.first)) {
503 LLVM_DEBUG({
504 dbgs() << "JITDylib unregistered to COFFPlatform detected in "
505 "LinkOrder: "
506 << CurJD->getName() << "\n";
507 });
508 continue;
509 }
510 }
511 DM.push_back(KV.first);
512 // Push unvisited entry.
513 if (JDDepMap.try_emplace(KV.first).second)
514 Worklist.push_back(KV.first);
515 }
516 });
517 }
518 return std::move(JDDepMap);
519 });
520}
521
522void COFFPlatform::pushInitializersLoop(PushInitializersSendResultFn SendResult,
523 JITDylibSP JD,
524 JITDylibDepMap &JDDepMap) {
525 SmallVector<JITDylib *, 16> Worklist({JD.get()});
526 DenseSet<JITDylib *> Visited({JD.get()});
527 DenseMap<JITDylib *, SymbolLookupSet> NewInitSymbols;
528 ES.runSessionLocked([&]() {
529 while (!Worklist.empty()) {
530 auto CurJD = Worklist.back();
531 Worklist.pop_back();
532
533 auto RISItr = RegisteredInitSymbols.find(CurJD);
534 if (RISItr != RegisteredInitSymbols.end()) {
535 NewInitSymbols[CurJD] = std::move(RISItr->second);
536 RegisteredInitSymbols.erase(RISItr);
537 }
538
539 for (auto *DepJD : JDDepMap[CurJD])
540 if (Visited.insert(DepJD).second)
541 Worklist.push_back(DepJD);
542 }
543 });
544
545 // If there are no further init symbols to look up then send the link order
546 // (as a list of header addresses) to the caller.
547 if (NewInitSymbols.empty()) {
548 // Build the dep info map to return.
549 COFFJITDylibDepInfoMap DIM;
550 DIM.reserve(JDDepMap.size());
551 for (auto &KV : JDDepMap) {
552 std::lock_guard<std::mutex> Lock(PlatformMutex);
553 COFFJITDylibDepInfo DepInfo;
554 DepInfo.reserve(KV.second.size());
555 for (auto &Dep : KV.second) {
556 DepInfo.push_back(JITDylibToHeaderAddr[Dep]);
557 }
558 auto H = JITDylibToHeaderAddr[KV.first];
559 DIM.push_back(std::make_pair(H, std::move(DepInfo)));
560 }
561 SendResult(DIM);
562 return;
563 }
564
565 // Otherwise issue a lookup and re-run this phase when it completes.
567 [this, SendResult = std::move(SendResult), &JD,
568 JDDepMap = std::move(JDDepMap)](Error Err) mutable {
569 if (Err)
570 SendResult(std::move(Err));
571 else
572 pushInitializersLoop(std::move(SendResult), JD, JDDepMap);
573 },
574 ES, std::move(NewInitSymbols));
575}
576
577void COFFPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
578 ExecutorAddr JDHeaderAddr) {
579 JITDylibSP JD;
580 {
581 std::lock_guard<std::mutex> Lock(PlatformMutex);
582 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
583 if (I != HeaderAddrToJITDylib.end())
584 JD = I->second;
585 }
586
587 LLVM_DEBUG({
588 dbgs() << "COFFPlatform::rt_pushInitializers(" << JDHeaderAddr << ") ";
589 if (JD)
590 dbgs() << "pushing initializers for " << JD->getName() << "\n";
591 else
592 dbgs() << "No JITDylib for header address.\n";
593 });
594
595 if (!JD) {
596 SendResult(make_error<StringError>("No JITDylib with header addr " +
597 formatv("{0:x}", JDHeaderAddr),
599 return;
600 }
601
602 auto JDDepMap = buildJDDepMap(*JD);
603 if (!JDDepMap) {
604 SendResult(JDDepMap.takeError());
605 return;
606 }
607
608 pushInitializersLoop(std::move(SendResult), JD, *JDDepMap);
609}
610
611void COFFPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
612 ExecutorAddr Handle, StringRef SymbolName) {
613 LLVM_DEBUG(dbgs() << "COFFPlatform::rt_lookupSymbol(\"" << Handle << "\")\n");
614
615 JITDylib *JD = nullptr;
616
617 {
618 std::lock_guard<std::mutex> Lock(PlatformMutex);
619 auto I = HeaderAddrToJITDylib.find(Handle);
620 if (I != HeaderAddrToJITDylib.end())
621 JD = I->second;
622 }
623
624 if (!JD) {
625 LLVM_DEBUG(dbgs() << " No JITDylib for handle " << Handle << "\n");
626 SendResult(make_error<StringError>("No JITDylib associated with handle " +
627 formatv("{0:x}", Handle),
629 return;
630 }
631
632 // Use functor class to work around XL build compiler issue on AIX.
633 class RtLookupNotifyComplete {
634 public:
635 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
636 : SendResult(std::move(SendResult)) {}
637 void operator()(Expected<SymbolMap> Result) {
638 if (Result) {
639 assert(Result->size() == 1 && "Unexpected result map count");
640 SendResult(Result->begin()->second.getAddress());
641 } else {
642 SendResult(Result.takeError());
643 }
644 }
645
646 private:
647 SendSymbolAddressFn SendResult;
648 };
649
650 ES.lookup(
652 SymbolLookupSet(ES.intern(SymbolName)), SymbolState::Ready,
653 RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
654}
655
656Error COFFPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
657 using LookupSymbolSPSSig =
658 SPSExpected<SPSExecutorAddr>(SPSExecutorAddr, SPSString);
659
660 using PushInitializersSPSSig =
661 SPSExpected<SPSCOFFJITDylibDepInfoMap>(SPSExecutorAddr);
662
663 return ES.registerCallControllerHandlers(
664 PlatformJD,
666 SymbolNameSpec::c("__orc_rt_coff_symbol_lookup_tag"), this,
667 &COFFPlatform::rt_lookupSymbol),
669 SymbolNameSpec::c("__orc_rt_coff_push_initializers_tag"), this,
670 &COFFPlatform::rt_pushInitializers));
671}
672
673Error COFFPlatform::runBootstrapInitializers(JDBootstrapState &BState) {
674 llvm::sort(BState.Initializers);
675 if (auto Err =
676 runBootstrapSubsectionInitializers(BState, ".CRT$XIA", ".CRT$XIZ"))
677 return Err;
678
679 if (auto Err = runSymbolIfExists(*BState.JD, "__run_after_c_init"))
680 return Err;
681
682 if (auto Err =
683 runBootstrapSubsectionInitializers(BState, ".CRT$XCA", ".CRT$XCZ"))
684 return Err;
685 return Error::success();
686}
687
688Error COFFPlatform::runBootstrapSubsectionInitializers(JDBootstrapState &BState,
689 StringRef Start,
690 StringRef End) {
691 CallInt32VoidProxy CallInitializer;
692 if (auto Err = lookupAndApply(
693 ES.getBootstrapJITDylib(),
694 {recordProxy<sps::CallInt32VoidProxySpec>(&CallInitializer)}))
695 return Err;
696 for (auto &Initializer : BState.Initializers)
697 if (Initializer.first >= Start && Initializer.first <= End &&
698 Initializer.second) {
699 auto Res = CallInitializer(ES, Initializer.second);
700 if (!Res)
701 return Res.takeError();
702 }
703 return Error::success();
704}
705
706Error COFFPlatform::bootstrapCOFFRuntime(JITDylib &PlatformJD) {
707 // Lookup of runtime symbols causes the collection of initializers if
708 // it's static linking setting.
709 if (auto Err = lookupAndApply(
710 PlatformJD,
711 {recordAddr(SymbolNameSpec::c("__orc_rt_coff_platform_bootstrap"),
712 &orc_rt_coff_platform_bootstrap),
713 recordAddr(SymbolNameSpec::c("__orc_rt_coff_platform_shutdown"),
714 &orc_rt_coff_platform_shutdown),
715 recordAddr(SymbolNameSpec::c("__orc_rt_coff_register_jitdylib"),
716 &orc_rt_coff_register_jitdylib),
717 recordAddr(SymbolNameSpec::c("__orc_rt_coff_deregister_jitdylib"),
718 &orc_rt_coff_deregister_jitdylib),
720 SymbolNameSpec::c("__orc_rt_coff_register_object_sections"),
721 &orc_rt_coff_register_object_sections),
723 SymbolNameSpec::c("__orc_rt_coff_deregister_object_sections"),
724 &orc_rt_coff_deregister_object_sections)}))
725 return Err;
726
727 // These runtime entry points are held as addresses because their primary use
728 // is as alloc-action tags (see the register/deregister sites below). The
729 // direct dispatches here are a bootstrap-time artifact, so rather than
730 // holding proxies as members we build them over the resolved addresses.
731 // TODO: drop these dispatches once bootstrap no longer needs them.
732 using PlatformBootstrapProxy = Proxy<void()>;
733 using RegisterJITDylibProxy = Proxy<void(std::string, ExecutorAddr)>;
734 using RegisterObjectSectionsProxy =
735 Proxy<void(ExecutorAddr, COFFObjectSectionsMap, bool)>;
736 using sps::ProxySpec;
737
738 PlatformBootstrapProxy PlatformBootstrap(
739 ProxySpec<PlatformBootstrapProxy,
740 coff_sps_ci::PlatformBootstrap>::dispatch,
741 orc_rt_coff_platform_bootstrap);
742 RegisterJITDylibProxy RegisterJITDylib(
743 ProxySpec<RegisterJITDylibProxy, coff_sps_ci::RegisterJITDylib>::dispatch,
744 orc_rt_coff_register_jitdylib);
745 RegisterObjectSectionsProxy RegisterObjectSections(
746 ProxySpec<RegisterObjectSectionsProxy,
747 coff_sps_ci::RegisterObjectSections>::dispatch,
748 orc_rt_coff_register_object_sections);
749
750 // Call bootstrap functions
751 if (auto Err = PlatformBootstrap(ES))
752 return Err;
753
754 // Do the pending jitdylib registration actions that we couldn't do
755 // because orc runtime was not linked fully.
756 for (auto KV : JDBootstrapStates) {
757 auto &JDBState = KV.second;
758 if (auto Err = RegisterJITDylib(ES, JDBState.JDName, JDBState.HeaderAddr))
759 return Err;
760
761 for (auto &ObjSectionMap : JDBState.ObjectSectionsMaps)
762 if (auto Err = RegisterObjectSections(ES, JDBState.HeaderAddr,
763 ObjSectionMap, false))
764 return Err;
765 }
766
767 // Run static initializers collected in bootstrap stage.
768 for (auto KV : JDBootstrapStates) {
769 auto &JDBState = KV.second;
770 if (auto Err = runBootstrapInitializers(JDBState))
771 return Err;
772 }
773
774 return Error::success();
775}
776
777Error COFFPlatform::runSymbolIfExists(JITDylib &PlatformJD,
778 StringRef SymbolName) {
779 ExecutorAddr TargetFn;
780 if (auto Err = lookupAndApply(
781 PlatformJD, {recordAddr(SymbolNameSpec::c(SymbolName), &TargetFn,
783 return Err;
784 if (!TargetFn)
785 return Error::success(); // No target function.
786
787 CallInt32VoidProxy CallFn;
788 if (auto Err =
789 lookupAndApply(ES.getBootstrapJITDylib(),
790 {recordProxy<sps::CallInt32VoidProxySpec>(&CallFn)}))
791 return Err;
792
793 return CallFn(ES, TargetFn).takeError();
794}
795
796void COFFPlatform::COFFPlatformPlugin::modifyPassConfig(
797 MaterializationResponsibility &MR, jitlink::LinkGraph &LG,
798 jitlink::PassConfiguration &Config) {
799
800 bool IsBootstrapping = CP.Bootstrapping.load();
801
802 if (auto InitSymbol = MR.getInitializerSymbol()) {
803 if (InitSymbol == CP.COFFHeaderStartSymbol) {
804 Config.PostAllocationPasses.push_back(
805 [this, &MR, IsBootstrapping](jitlink::LinkGraph &G) {
806 return associateJITDylibHeaderSymbol(G, MR, IsBootstrapping);
807 });
808 return;
809 }
810 Config.PrePrunePasses.push_back([this, &MR](jitlink::LinkGraph &G) {
811 return preserveInitializerSections(G, MR);
812 });
813 }
814
815 if (!IsBootstrapping)
816 Config.PostFixupPasses.push_back(
817 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
818 return registerObjectPlatformSections(G, JD);
819 });
820 else
821 Config.PostFixupPasses.push_back(
822 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
823 return registerObjectPlatformSectionsInBootstrap(G, JD);
824 });
825}
826
827Error COFFPlatform::COFFPlatformPlugin::associateJITDylibHeaderSymbol(
828 jitlink::LinkGraph &G, MaterializationResponsibility &MR,
829 bool IsBootstraping) {
830 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
831 return *Sym->getName() == *CP.COFFHeaderStartSymbol;
832 });
833 assert(I != G.defined_symbols().end() && "Missing COFF header start symbol");
834
835 auto &JD = MR.getTargetJITDylib();
836 std::lock_guard<std::mutex> Lock(CP.PlatformMutex);
837 auto HeaderAddr = (*I)->getAddress();
838 CP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
839 CP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
840 if (!IsBootstraping) {
841 G.allocActions().push_back(
843 SPSArgList<SPSString, SPSExecutorAddr>>(
844 CP.orc_rt_coff_register_jitdylib, JD.getName(), HeaderAddr)),
845 cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
846 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
847 } else {
848 G.allocActions().push_back(
849 {{},
850 cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
851 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
852 JDBootstrapState BState;
853 BState.JD = &JD;
854 BState.JDName = JD.getName();
855 BState.HeaderAddr = HeaderAddr;
856 CP.JDBootstrapStates.emplace(&JD, BState);
857 }
858
859 return Error::success();
860}
861
862Error COFFPlatform::COFFPlatformPlugin::registerObjectPlatformSections(
863 jitlink::LinkGraph &G, JITDylib &JD) {
864 COFFObjectSectionsMap ObjSecs;
865 auto HeaderAddr = CP.JITDylibToHeaderAddr[&JD];
866 assert(HeaderAddr && "Must be registered jitdylib");
867 for (auto &S : G.sections()) {
868 jitlink::SectionRange Range(S);
869 if (Range.getSize())
870 ObjSecs.push_back(std::make_pair(S.getName().str(), Range.getRange()));
871 }
872
873 G.allocActions().push_back(
875 CP.orc_rt_coff_register_object_sections, HeaderAddr, ObjSecs, true)),
876 cantFail(
878 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
879 ObjSecs))});
880
881 return Error::success();
882}
883
884Error COFFPlatform::COFFPlatformPlugin::preserveInitializerSections(
885 jitlink::LinkGraph &G, MaterializationResponsibility &MR) {
886
887 if (const auto &InitSymName = MR.getInitializerSymbol()) {
888
889 jitlink::Symbol *InitSym = nullptr;
890
891 for (auto &InitSection : G.sections()) {
892 // Skip non-init sections.
893 if (!isCOFFInitializerSection(InitSection.getName()) ||
894 InitSection.empty())
895 continue;
896
897 // Create the init symbol if it has not been created already and attach it
898 // to the first block.
899 if (!InitSym) {
900 auto &B = **InitSection.blocks().begin();
901 InitSym = &G.addDefinedSymbol(
902 B, 0, *InitSymName, B.getSize(), jitlink::Linkage::Strong,
904 }
905
906 // Add keep-alive edges to anonymous symbols in all other init blocks.
907 for (auto *B : InitSection.blocks()) {
908 if (B == &InitSym->getBlock())
909 continue;
910
911 auto &S = G.addAnonymousSymbol(*B, 0, B->getSize(), false, true);
912 InitSym->getBlock().addEdge(jitlink::Edge::KeepAlive, 0, S, 0);
913 }
914 }
915 }
916
917 return Error::success();
918}
919
920Error COFFPlatform::COFFPlatformPlugin::
921 registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &G,
922 JITDylib &JD) {
923 std::lock_guard<std::mutex> Lock(CP.PlatformMutex);
924 auto HeaderAddr = CP.JITDylibToHeaderAddr[&JD];
925 COFFObjectSectionsMap ObjSecs;
926 for (auto &S : G.sections()) {
927 jitlink::SectionRange Range(S);
928 if (Range.getSize())
929 ObjSecs.push_back(std::make_pair(S.getName().str(), Range.getRange()));
930 }
931
932 G.allocActions().push_back(
933 {{},
934 cantFail(
936 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
937 ObjSecs))});
938
939 auto &BState = CP.JDBootstrapStates[&JD];
940 BState.ObjectSectionsMaps.push_back(std::move(ObjSecs));
941
942 // Collect static initializers
943 for (auto &S : G.sections())
944 if (isCOFFInitializerSection(S.getName()))
945 for (auto *B : S.blocks()) {
946 if (B->edges_empty())
947 continue;
948 for (auto &E : B->edges())
949 BState.Initializers.push_back(std::make_pair(
950 S.getName().str(), E.getTarget().getAddress() + E.getAddend()));
951 }
952
953 return Error::success();
954}
955
956} // End namespace orc.
957} // End namespace llvm.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
#define _
#define offsetof(TYPE, MEMBER)
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define H(x, y, z)
Definition MD5.cpp:56
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define P(N)
static StringRef getName(Value *V)
#define LLVM_DEBUG(...)
Definition Debug.h:119
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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:778
Helper for Errors used as out-parameters.
Definition Error.h:1160
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
static Expected< std::unique_ptr< Archive > > create(MemoryBufferRef Source)
Definition Archive.cpp:785
Mediates between COFF initialization and ExecutionSession state.
Error setupJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
static Expected< std::unique_ptr< COFFPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< MemoryBuffer > OrcRuntimeArchiveBuffer, LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime=false, const char *VCRuntimePath=nullptr, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a COFFPlatform instance, adding the ORC runtime to the given JITDylib.
unique_function< Error(JITDylib &JD, StringRef DLLFileName)> LoadDynamicLibrary
A function that will be called with the name of dll file that must be loaded.
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases()
Returns the array of standard runtime utility aliases for COFF.
Error teardownJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
static SymbolAliasMap standardPlatformAliases(ExecutionSession &ES)
Returns an AliasMap containing the default aliases for the COFFPlatform.
Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU) override
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases()
Returns the array of required CXX aliases.
Error notifyRemoving(ResourceTracker &RT) override
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
static LLVM_ABI Expected< std::unique_ptr< COFFVCRuntimeBootstrapper > > Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, const char *RuntimePath=nullptr)
Try to create a COFFVCRuntimeBootstrapper instance.
static std::unique_ptr< DLLImportDefinitionGenerator > Create(ExecutionSession &ES, ObjectLinkingLayer &L)
Creates a DLLImportDefinitionGenerator instance.
An ExecutionSession represents a running JIT program.
Definition Core.h:1112
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition Core.h:1193
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition Core.h:676
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:1629
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition Core.h:1612
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Definition Mangling.h:28
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:350
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition Core.h:389
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition Core.h:375
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.
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
An ObjectLayer implementation built on JITLink.
static void lookupInitSymbolsAsync(unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
Performs an async lookup for the given symbols in each of the given JITDylibs, calling the given hand...
Definition Core.cpp:1489
API to remove / transfer ownership of JIT resources.
Definition Core.h:64
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition Core.h:79
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Create(ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, std::unique_ptr< object::Archive > Archive, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
static constexpr SymbolNameSpec c(StringRef Name)
Pointer to a pooled string representing a symbol name.
A utility class for serializing to a blob from a variadic list.
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.
@ IMAGE_FILE_MACHINE_AMD64
Definition COFF.h:98
@ NUM_DATA_DIRECTORIES
Definition COFF.h:647
static const char PEMagic[]
Definition COFF.h:36
SPSSequence< SPSExecutorAddr > SPSCOFFJITDylibDepInfo
SPSSequence< char > SPSString
SPS tag type for strings, which are equivalent to sequences of chars.
SPSArgList< SPSExecutorAddr, SPSCOFFObjectSectionsMap, bool > SPSCOFFRegisterObjectSectionsArgs
SPSSequence< SPSTuple< SPSString, SPSExecutorAddrRange > > SPSCOFFObjectSectionsMap
SPSSequence< SPSTuple< SPSExecutorAddr, SPSCOFFJITDylibDepInfo > > SPSCOFFJITDylibDepInfoMap
SPSArgList< SPSExecutorAddr, SPSCOFFObjectSectionsMap > SPSCOFFDeregisterObjectSectionsArgs
ExecutionSession::CallControllerHandlerBinding bindCallControllerHandlerSPS(SymbolNameSpec Name, HandlerT &&Handler, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
Bind a call-controller handler that takes concrete argument types (and a sender for a concrete return...
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
Definition Core.h:149
IntrusiveRefCntPtr< JITDylib > JITDylibSP
Definition Core.h:59
Proxy< int32_t(ExecutorAddr)> CallInt32VoidProxy
Protocol-agnostic interface for running an int32_t() function in the executor.
Definition CallProxies.h:45
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition Core.h:524
LLVM_ABI void lookupAndApply(unique_function< void(Error)> OnApplied, LookupKind K, const JITDylibSearchOrder &SearchOrder, ArrayRef< LookupPrepareFn > PrepareFns)
Resolve the symbols contributed by every prepare function with a single lookup, then let each of thei...
std::unique_ptr< ReExportsMaterializationUnit > reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, JITDylibLookupFlags SourceJDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Create a materialization unit for re-exporting symbols from another JITDylib with alternative names/f...
Definition Core.h:533
LookupPrepareFn recordAddr(SymbolNameSpec Name, ExecutorAddr *A, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
Records the address of the symbol with the given name.
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
LLVM_ABI Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
jitlink::Block & createHeaderBlock(MachOPlatform &MOP, const MachOPlatform::HeaderOptions &Opts, JITDylib &JD, jitlink::LinkGraph &G, jitlink::Section &HeaderSection)
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition Core.cpp:41
LLVM_ABI bool isCOFFInitializerSection(StringRef Name)
@ Ready
Emitted to memory, but waiting on transitive dependencies.
Definition Core.h:552
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:174
LLVM_ABI Expected< SymbolAliasMap > buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols)
Build a SymbolAliasMap for the common case where you want to re-export symbols from another JITDylib ...
Definition Core.cpp:483
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
Definition Endian.h:270
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition Error.h:1415
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1652
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
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:1933
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
static constexpr SymbolNameSpec Name
void(SPSString, SPSExecutorAddr) SPSSig
static constexpr SymbolNameSpec Name
void(SPSExecutorAddr, SPSCOFFObjectSectionsMap, bool) SPSSig