ExecutionUtils.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. //===---- ExecutionUtils.cpp - Utilities for executing functions 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. #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
  9. #include "llvm/ExecutionEngine/JITLink/x86_64.h"
  10. #include "llvm/ExecutionEngine/Orc/Layer.h"
  11. #include "llvm/ExecutionEngine/Orc/ObjectFileInterface.h"
  12. #include "llvm/IR/Constants.h"
  13. #include "llvm/IR/Function.h"
  14. #include "llvm/IR/GlobalVariable.h"
  15. #include "llvm/IR/Module.h"
  16. #include "llvm/MC/TargetRegistry.h"
  17. #include "llvm/Object/MachOUniversal.h"
  18. #include "llvm/Support/FormatVariadic.h"
  19. #include "llvm/Target/TargetMachine.h"
  20. #include <string>
  21. namespace llvm {
  22. namespace orc {
  23. CtorDtorIterator::CtorDtorIterator(const GlobalVariable *GV, bool End)
  24. : InitList(
  25. GV ? dyn_cast_or_null<ConstantArray>(GV->getInitializer()) : nullptr),
  26. I((InitList && End) ? InitList->getNumOperands() : 0) {
  27. }
  28. bool CtorDtorIterator::operator==(const CtorDtorIterator &Other) const {
  29. assert(InitList == Other.InitList && "Incomparable iterators.");
  30. return I == Other.I;
  31. }
  32. bool CtorDtorIterator::operator!=(const CtorDtorIterator &Other) const {
  33. return !(*this == Other);
  34. }
  35. CtorDtorIterator& CtorDtorIterator::operator++() {
  36. ++I;
  37. return *this;
  38. }
  39. CtorDtorIterator CtorDtorIterator::operator++(int) {
  40. CtorDtorIterator Temp = *this;
  41. ++I;
  42. return Temp;
  43. }
  44. CtorDtorIterator::Element CtorDtorIterator::operator*() const {
  45. ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(I));
  46. assert(CS && "Unrecognized type in llvm.global_ctors/llvm.global_dtors");
  47. Constant *FuncC = CS->getOperand(1);
  48. Function *Func = nullptr;
  49. // Extract function pointer, pulling off any casts.
  50. while (FuncC) {
  51. if (Function *F = dyn_cast_or_null<Function>(FuncC)) {
  52. Func = F;
  53. break;
  54. } else if (ConstantExpr *CE = dyn_cast_or_null<ConstantExpr>(FuncC)) {
  55. if (CE->isCast())
  56. FuncC = CE->getOperand(0);
  57. else
  58. break;
  59. } else {
  60. // This isn't anything we recognize. Bail out with Func left set to null.
  61. break;
  62. }
  63. }
  64. auto *Priority = cast<ConstantInt>(CS->getOperand(0));
  65. Value *Data = CS->getNumOperands() == 3 ? CS->getOperand(2) : nullptr;
  66. if (Data && !isa<GlobalValue>(Data))
  67. Data = nullptr;
  68. return Element(Priority->getZExtValue(), Func, Data);
  69. }
  70. iterator_range<CtorDtorIterator> getConstructors(const Module &M) {
  71. const GlobalVariable *CtorsList = M.getNamedGlobal("llvm.global_ctors");
  72. return make_range(CtorDtorIterator(CtorsList, false),
  73. CtorDtorIterator(CtorsList, true));
  74. }
  75. iterator_range<CtorDtorIterator> getDestructors(const Module &M) {
  76. const GlobalVariable *DtorsList = M.getNamedGlobal("llvm.global_dtors");
  77. return make_range(CtorDtorIterator(DtorsList, false),
  78. CtorDtorIterator(DtorsList, true));
  79. }
  80. bool StaticInitGVIterator::isStaticInitGlobal(GlobalValue &GV) {
  81. if (GV.isDeclaration())
  82. return false;
  83. if (GV.hasName() && (GV.getName() == "llvm.global_ctors" ||
  84. GV.getName() == "llvm.global_dtors"))
  85. return true;
  86. if (ObjFmt == Triple::MachO) {
  87. // FIXME: These section checks are too strict: We should match first and
  88. // second word split by comma.
  89. if (GV.hasSection() &&
  90. (GV.getSection().startswith("__DATA,__objc_classlist") ||
  91. GV.getSection().startswith("__DATA,__objc_selrefs")))
  92. return true;
  93. }
  94. return false;
  95. }
  96. void CtorDtorRunner::add(iterator_range<CtorDtorIterator> CtorDtors) {
  97. if (CtorDtors.empty())
  98. return;
  99. MangleAndInterner Mangle(
  100. JD.getExecutionSession(),
  101. (*CtorDtors.begin()).Func->getParent()->getDataLayout());
  102. for (auto CtorDtor : CtorDtors) {
  103. assert(CtorDtor.Func && CtorDtor.Func->hasName() &&
  104. "Ctor/Dtor function must be named to be runnable under the JIT");
  105. // FIXME: Maybe use a symbol promoter here instead.
  106. if (CtorDtor.Func->hasLocalLinkage()) {
  107. CtorDtor.Func->setLinkage(GlobalValue::ExternalLinkage);
  108. CtorDtor.Func->setVisibility(GlobalValue::HiddenVisibility);
  109. }
  110. if (CtorDtor.Data && cast<GlobalValue>(CtorDtor.Data)->isDeclaration()) {
  111. dbgs() << " Skipping because why now?\n";
  112. continue;
  113. }
  114. CtorDtorsByPriority[CtorDtor.Priority].push_back(
  115. Mangle(CtorDtor.Func->getName()));
  116. }
  117. }
  118. Error CtorDtorRunner::run() {
  119. using CtorDtorTy = void (*)();
  120. SymbolLookupSet LookupSet;
  121. for (auto &KV : CtorDtorsByPriority)
  122. for (auto &Name : KV.second)
  123. LookupSet.add(Name);
  124. assert(!LookupSet.containsDuplicates() &&
  125. "Ctor/Dtor list contains duplicates");
  126. auto &ES = JD.getExecutionSession();
  127. if (auto CtorDtorMap = ES.lookup(
  128. makeJITDylibSearchOrder(&JD, JITDylibLookupFlags::MatchAllSymbols),
  129. std::move(LookupSet))) {
  130. for (auto &KV : CtorDtorsByPriority) {
  131. for (auto &Name : KV.second) {
  132. assert(CtorDtorMap->count(Name) && "No entry for Name");
  133. auto CtorDtor = reinterpret_cast<CtorDtorTy>(
  134. static_cast<uintptr_t>((*CtorDtorMap)[Name].getAddress()));
  135. CtorDtor();
  136. }
  137. }
  138. CtorDtorsByPriority.clear();
  139. return Error::success();
  140. } else
  141. return CtorDtorMap.takeError();
  142. }
  143. void LocalCXXRuntimeOverridesBase::runDestructors() {
  144. auto& CXXDestructorDataPairs = DSOHandleOverride;
  145. for (auto &P : CXXDestructorDataPairs)
  146. P.first(P.second);
  147. CXXDestructorDataPairs.clear();
  148. }
  149. int LocalCXXRuntimeOverridesBase::CXAAtExitOverride(DestructorPtr Destructor,
  150. void *Arg,
  151. void *DSOHandle) {
  152. auto& CXXDestructorDataPairs =
  153. *reinterpret_cast<CXXDestructorDataPairList*>(DSOHandle);
  154. CXXDestructorDataPairs.push_back(std::make_pair(Destructor, Arg));
  155. return 0;
  156. }
  157. Error LocalCXXRuntimeOverrides::enable(JITDylib &JD,
  158. MangleAndInterner &Mangle) {
  159. SymbolMap RuntimeInterposes;
  160. RuntimeInterposes[Mangle("__dso_handle")] =
  161. JITEvaluatedSymbol(toTargetAddress(&DSOHandleOverride),
  162. JITSymbolFlags::Exported);
  163. RuntimeInterposes[Mangle("__cxa_atexit")] =
  164. JITEvaluatedSymbol(toTargetAddress(&CXAAtExitOverride),
  165. JITSymbolFlags::Exported);
  166. return JD.define(absoluteSymbols(std::move(RuntimeInterposes)));
  167. }
  168. void ItaniumCXAAtExitSupport::registerAtExit(void (*F)(void *), void *Ctx,
  169. void *DSOHandle) {
  170. std::lock_guard<std::mutex> Lock(AtExitsMutex);
  171. AtExitRecords[DSOHandle].push_back({F, Ctx});
  172. }
  173. void ItaniumCXAAtExitSupport::runAtExits(void *DSOHandle) {
  174. std::vector<AtExitRecord> AtExitsToRun;
  175. {
  176. std::lock_guard<std::mutex> Lock(AtExitsMutex);
  177. auto I = AtExitRecords.find(DSOHandle);
  178. if (I != AtExitRecords.end()) {
  179. AtExitsToRun = std::move(I->second);
  180. AtExitRecords.erase(I);
  181. }
  182. }
  183. while (!AtExitsToRun.empty()) {
  184. AtExitsToRun.back().F(AtExitsToRun.back().Ctx);
  185. AtExitsToRun.pop_back();
  186. }
  187. }
  188. DynamicLibrarySearchGenerator::DynamicLibrarySearchGenerator(
  189. sys::DynamicLibrary Dylib, char GlobalPrefix, SymbolPredicate Allow)
  190. : Dylib(std::move(Dylib)), Allow(std::move(Allow)),
  191. GlobalPrefix(GlobalPrefix) {}
  192. Expected<std::unique_ptr<DynamicLibrarySearchGenerator>>
  193. DynamicLibrarySearchGenerator::Load(const char *FileName, char GlobalPrefix,
  194. SymbolPredicate Allow) {
  195. std::string ErrMsg;
  196. auto Lib = sys::DynamicLibrary::getPermanentLibrary(FileName, &ErrMsg);
  197. if (!Lib.isValid())
  198. return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
  199. return std::make_unique<DynamicLibrarySearchGenerator>(
  200. std::move(Lib), GlobalPrefix, std::move(Allow));
  201. }
  202. Error DynamicLibrarySearchGenerator::tryToGenerate(
  203. LookupState &LS, LookupKind K, JITDylib &JD,
  204. JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
  205. orc::SymbolMap NewSymbols;
  206. bool HasGlobalPrefix = (GlobalPrefix != '\0');
  207. for (auto &KV : Symbols) {
  208. auto &Name = KV.first;
  209. if ((*Name).empty())
  210. continue;
  211. if (Allow && !Allow(Name))
  212. continue;
  213. if (HasGlobalPrefix && (*Name).front() != GlobalPrefix)
  214. continue;
  215. std::string Tmp((*Name).data() + HasGlobalPrefix,
  216. (*Name).size() - HasGlobalPrefix);
  217. if (void *Addr = Dylib.getAddressOfSymbol(Tmp.c_str())) {
  218. NewSymbols[Name] = JITEvaluatedSymbol(
  219. static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(Addr)),
  220. JITSymbolFlags::Exported);
  221. }
  222. }
  223. if (NewSymbols.empty())
  224. return Error::success();
  225. return JD.define(absoluteSymbols(std::move(NewSymbols)));
  226. }
  227. Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
  228. StaticLibraryDefinitionGenerator::Load(
  229. ObjectLayer &L, const char *FileName,
  230. GetObjectFileInterface GetObjFileInterface) {
  231. auto ArchiveBuffer = MemoryBuffer::getFile(FileName);
  232. if (!ArchiveBuffer)
  233. return createFileError(FileName, ArchiveBuffer.getError());
  234. return Create(L, std::move(*ArchiveBuffer), std::move(GetObjFileInterface));
  235. }
  236. Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
  237. StaticLibraryDefinitionGenerator::Load(
  238. ObjectLayer &L, const char *FileName, const Triple &TT,
  239. GetObjectFileInterface GetObjFileInterface) {
  240. auto B = object::createBinary(FileName);
  241. if (!B)
  242. return createFileError(FileName, B.takeError());
  243. // If this is a regular archive then create an instance from it.
  244. if (isa<object::Archive>(B->getBinary()))
  245. return Create(L, std::move(B->takeBinary().second),
  246. std::move(GetObjFileInterface));
  247. // If this is a universal binary then search for a slice matching the given
  248. // Triple.
  249. if (auto *UB = cast<object::MachOUniversalBinary>(B->getBinary())) {
  250. for (const auto &Obj : UB->objects()) {
  251. auto ObjTT = Obj.getTriple();
  252. if (ObjTT.getArch() == TT.getArch() &&
  253. ObjTT.getSubArch() == TT.getSubArch() &&
  254. (TT.getVendor() == Triple::UnknownVendor ||
  255. ObjTT.getVendor() == TT.getVendor())) {
  256. // We found a match. Create an instance from a buffer covering this
  257. // slice.
  258. auto SliceBuffer = MemoryBuffer::getFileSlice(FileName, Obj.getSize(),
  259. Obj.getOffset());
  260. if (!SliceBuffer)
  261. return make_error<StringError>(
  262. Twine("Could not create buffer for ") + TT.str() + " slice of " +
  263. FileName + ": [ " + formatv("{0:x}", Obj.getOffset()) +
  264. " .. " + formatv("{0:x}", Obj.getOffset() + Obj.getSize()) +
  265. ": " + SliceBuffer.getError().message(),
  266. SliceBuffer.getError());
  267. return Create(L, std::move(*SliceBuffer),
  268. std::move(GetObjFileInterface));
  269. }
  270. }
  271. return make_error<StringError>(Twine("Universal binary ") + FileName +
  272. " does not contain a slice for " +
  273. TT.str(),
  274. inconvertibleErrorCode());
  275. }
  276. return make_error<StringError>(Twine("Unrecognized file type for ") +
  277. FileName,
  278. inconvertibleErrorCode());
  279. }
  280. Expected<std::unique_ptr<StaticLibraryDefinitionGenerator>>
  281. StaticLibraryDefinitionGenerator::Create(
  282. ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
  283. GetObjectFileInterface GetObjFileInterface) {
  284. Error Err = Error::success();
  285. std::unique_ptr<StaticLibraryDefinitionGenerator> ADG(
  286. new StaticLibraryDefinitionGenerator(
  287. L, std::move(ArchiveBuffer), std::move(GetObjFileInterface), Err));
  288. if (Err)
  289. return std::move(Err);
  290. return std::move(ADG);
  291. }
  292. Error StaticLibraryDefinitionGenerator::tryToGenerate(
  293. LookupState &LS, LookupKind K, JITDylib &JD,
  294. JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
  295. // Don't materialize symbols from static archives unless this is a static
  296. // lookup.
  297. if (K != LookupKind::Static)
  298. return Error::success();
  299. // Bail out early if we've already freed the archive.
  300. if (!Archive)
  301. return Error::success();
  302. DenseSet<std::pair<StringRef, StringRef>> ChildBufferInfos;
  303. for (const auto &KV : Symbols) {
  304. const auto &Name = KV.first;
  305. if (!ObjectFilesMap.count(Name))
  306. continue;
  307. auto ChildBuffer = ObjectFilesMap[Name];
  308. ChildBufferInfos.insert(
  309. {ChildBuffer.getBuffer(), ChildBuffer.getBufferIdentifier()});
  310. }
  311. for (auto ChildBufferInfo : ChildBufferInfos) {
  312. MemoryBufferRef ChildBufferRef(ChildBufferInfo.first,
  313. ChildBufferInfo.second);
  314. auto I = GetObjFileInterface(L.getExecutionSession(), ChildBufferRef);
  315. if (!I)
  316. return I.takeError();
  317. if (auto Err = L.add(JD, MemoryBuffer::getMemBuffer(ChildBufferRef, false),
  318. std::move(*I)))
  319. return Err;
  320. }
  321. return Error::success();
  322. }
  323. Error StaticLibraryDefinitionGenerator::buildObjectFilesMap() {
  324. DenseMap<uint64_t, MemoryBufferRef> MemoryBuffers;
  325. DenseSet<uint64_t> Visited;
  326. DenseSet<uint64_t> Excluded;
  327. for (auto &S : Archive->symbols()) {
  328. StringRef SymName = S.getName();
  329. auto Member = S.getMember();
  330. if (!Member)
  331. return Member.takeError();
  332. auto DataOffset = Member->getDataOffset();
  333. if (!Visited.count(DataOffset)) {
  334. Visited.insert(DataOffset);
  335. auto Child = Member->getAsBinary();
  336. if (!Child)
  337. return Child.takeError();
  338. if ((*Child)->isCOFFImportFile()) {
  339. ImportedDynamicLibraries.insert((*Child)->getFileName().str());
  340. Excluded.insert(DataOffset);
  341. continue;
  342. }
  343. MemoryBuffers[DataOffset] = (*Child)->getMemoryBufferRef();
  344. }
  345. if (!Excluded.count(DataOffset))
  346. ObjectFilesMap[L.getExecutionSession().intern(SymName)] =
  347. MemoryBuffers[DataOffset];
  348. }
  349. return Error::success();
  350. }
  351. StaticLibraryDefinitionGenerator::StaticLibraryDefinitionGenerator(
  352. ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
  353. GetObjectFileInterface GetObjFileInterface, Error &Err)
  354. : L(L), GetObjFileInterface(std::move(GetObjFileInterface)),
  355. ArchiveBuffer(std::move(ArchiveBuffer)),
  356. Archive(std::make_unique<object::Archive>(*this->ArchiveBuffer, Err)) {
  357. ErrorAsOutParameter _(&Err);
  358. if (!this->GetObjFileInterface)
  359. this->GetObjFileInterface = getObjectFileInterface;
  360. if (!Err)
  361. Err = buildObjectFilesMap();
  362. }
  363. std::unique_ptr<DLLImportDefinitionGenerator>
  364. DLLImportDefinitionGenerator::Create(ExecutionSession &ES,
  365. ObjectLinkingLayer &L) {
  366. return std::unique_ptr<DLLImportDefinitionGenerator>(
  367. new DLLImportDefinitionGenerator(ES, L));
  368. }
  369. Error DLLImportDefinitionGenerator::tryToGenerate(
  370. LookupState &LS, LookupKind K, JITDylib &JD,
  371. JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
  372. JITDylibSearchOrder LinkOrder;
  373. JD.withLinkOrderDo([&](const JITDylibSearchOrder &LO) {
  374. LinkOrder.reserve(LO.size());
  375. for (auto &KV : LO) {
  376. if (KV.first == &JD)
  377. continue;
  378. LinkOrder.push_back(KV);
  379. }
  380. });
  381. // FIXME: if regular symbol name start with __imp_ we have to issue lookup of
  382. // both __imp_ and stripped name and use the lookup information to resolve the
  383. // real symbol name.
  384. SymbolLookupSet LookupSet;
  385. DenseMap<StringRef, SymbolLookupFlags> ToLookUpSymbols;
  386. for (auto &KV : Symbols) {
  387. StringRef Deinterned = *KV.first;
  388. if (Deinterned.startswith(getImpPrefix()))
  389. Deinterned = Deinterned.drop_front(StringRef(getImpPrefix()).size());
  390. // Don't degrade the required state
  391. if (ToLookUpSymbols.count(Deinterned) &&
  392. ToLookUpSymbols[Deinterned] == SymbolLookupFlags::RequiredSymbol)
  393. continue;
  394. ToLookUpSymbols[Deinterned] = KV.second;
  395. }
  396. for (auto &KV : ToLookUpSymbols)
  397. LookupSet.add(ES.intern(KV.first), KV.second);
  398. auto Resolved =
  399. ES.lookup(LinkOrder, LookupSet, LookupKind::DLSym, SymbolState::Resolved);
  400. if (!Resolved)
  401. return Resolved.takeError();
  402. auto G = createStubsGraph(*Resolved);
  403. if (!G)
  404. return G.takeError();
  405. return L.add(JD, std::move(*G));
  406. }
  407. Expected<unsigned>
  408. DLLImportDefinitionGenerator::getTargetPointerSize(const Triple &TT) {
  409. switch (TT.getArch()) {
  410. case Triple::x86_64:
  411. return 8;
  412. default:
  413. return make_error<StringError>(
  414. "architecture unsupported by DLLImportDefinitionGenerator",
  415. inconvertibleErrorCode());
  416. }
  417. }
  418. Expected<support::endianness>
  419. DLLImportDefinitionGenerator::getTargetEndianness(const Triple &TT) {
  420. switch (TT.getArch()) {
  421. case Triple::x86_64:
  422. return support::endianness::little;
  423. default:
  424. return make_error<StringError>(
  425. "architecture unsupported by DLLImportDefinitionGenerator",
  426. inconvertibleErrorCode());
  427. }
  428. }
  429. Expected<std::unique_ptr<jitlink::LinkGraph>>
  430. DLLImportDefinitionGenerator::createStubsGraph(const SymbolMap &Resolved) {
  431. Triple TT = ES.getExecutorProcessControl().getTargetTriple();
  432. auto PointerSize = getTargetEndianness(TT);
  433. if (!PointerSize)
  434. return PointerSize.takeError();
  435. auto Endianness = getTargetEndianness(TT);
  436. if (!Endianness)
  437. return Endianness.takeError();
  438. auto G = std::make_unique<jitlink::LinkGraph>(
  439. "<DLLIMPORT_STUBS>", TT, *PointerSize, *Endianness,
  440. jitlink::getGenericEdgeKindName);
  441. jitlink::Section &Sec =
  442. G->createSection(getSectionName(), MemProt::Read | MemProt::Exec);
  443. for (auto &KV : Resolved) {
  444. jitlink::Symbol &Target = G->addAbsoluteSymbol(
  445. *KV.first, ExecutorAddr(KV.second.getAddress()), *PointerSize,
  446. jitlink::Linkage::Strong, jitlink::Scope::Local, false);
  447. // Create __imp_ symbol
  448. jitlink::Symbol &Ptr =
  449. jitlink::x86_64::createAnonymousPointer(*G, Sec, &Target);
  450. auto NameCopy = G->allocateString(Twine(getImpPrefix()) + *KV.first);
  451. StringRef NameCopyRef = StringRef(NameCopy.data(), NameCopy.size());
  452. Ptr.setName(NameCopyRef);
  453. Ptr.setLinkage(jitlink::Linkage::Strong);
  454. Ptr.setScope(jitlink::Scope::Default);
  455. // Create PLT stub
  456. // FIXME: check PLT stub of data symbol is not accessed
  457. jitlink::Block &StubBlock =
  458. jitlink::x86_64::createPointerJumpStubBlock(*G, Sec, Ptr);
  459. G->addDefinedSymbol(StubBlock, 0, *KV.first, StubBlock.getSize(),
  460. jitlink::Linkage::Strong, jitlink::Scope::Default, true,
  461. false);
  462. }
  463. return std::move(G);
  464. }
  465. } // End namespace orc.
  466. } // End namespace llvm.