blob: 269597a29a30daec15e7e55a00e547db3b1b2e2f [file] [log] [blame]
Lang Hames11c8dfa52019-04-20 17:10:34 +00001//===---- llvm-jitlink.h - Session and format-specific decls ----*- C++ -*-===//
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//
9// Utilities for remote-JITing with LLI.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
14#define LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
15
16#include "llvm/ADT/Triple.h"
17#include "llvm/ExecutionEngine/Orc/Core.h"
18#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
19#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
20#include "llvm/Support/Error.h"
21#include "llvm/Support/raw_ostream.h"
22
23#include <vector>
24
25namespace llvm {
26
27struct Session {
28 orc::ExecutionSession ES;
Lang Hames335676e2019-09-06 19:21:55 +000029 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr;
Lang Hames11c8dfa52019-04-20 17:10:34 +000030 orc::ObjectLinkingLayer ObjLayer;
31 std::vector<orc::JITDylib *> JDSearchOrder;
32 Triple TT;
33
34 Session(Triple TT);
35 void dumpSessionInfo(raw_ostream &OS);
36 void modifyPassConfig(const Triple &FTT,
37 jitlink::PassConfiguration &PassConfig);
38
39 using MemoryRegionInfo = RuntimeDyldChecker::MemoryRegionInfo;
40
41 struct FileInfo {
42 StringMap<MemoryRegionInfo> SectionInfos;
43 StringMap<MemoryRegionInfo> StubInfos;
44 StringMap<MemoryRegionInfo> GOTEntryInfos;
45 };
46
47 using SymbolInfoMap = StringMap<MemoryRegionInfo>;
48 using FileInfoMap = StringMap<FileInfo>;
49
50 Expected<FileInfo &> findFileInfo(StringRef FileName);
51 Expected<MemoryRegionInfo &> findSectionInfo(StringRef FileName,
52 StringRef SectionName);
53 Expected<MemoryRegionInfo &> findStubInfo(StringRef FileName,
54 StringRef TargetName);
55 Expected<MemoryRegionInfo &> findGOTEntryInfo(StringRef FileName,
56 StringRef TargetName);
57
58 bool isSymbolRegistered(StringRef Name);
59 Expected<MemoryRegionInfo &> findSymbolInfo(StringRef SymbolName,
60 Twine ErrorMsgStem);
61
62 SymbolInfoMap SymbolInfos;
63 FileInfoMap FileInfos;
64 uint64_t SizeBeforePruning = 0;
65 uint64_t SizeAfterFixups = 0;
66};
67
68Error registerMachOStubsAndGOT(Session &S, jitlink::AtomGraph &G);
69
70} // end namespace llvm
71
72#endif // LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H