1 //===---- llvm-jitlink.h - Session and format-specific decls ----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Utilities for remote-JITing with LLI.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
14 #define LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
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"
28 orc::ExecutionSession ES
;
29 std::unique_ptr
<jitlink::JITLinkMemoryManager
> MemMgr
;
30 orc::ObjectLinkingLayer ObjLayer
;
31 std::vector
<orc::JITDylib
*> JDSearchOrder
;
35 void dumpSessionInfo(raw_ostream
&OS
);
36 void modifyPassConfig(const Triple
&FTT
,
37 jitlink::PassConfiguration
&PassConfig
);
39 using MemoryRegionInfo
= RuntimeDyldChecker::MemoryRegionInfo
;
42 StringMap
<MemoryRegionInfo
> SectionInfos
;
43 StringMap
<MemoryRegionInfo
> StubInfos
;
44 StringMap
<MemoryRegionInfo
> GOTEntryInfos
;
47 using SymbolInfoMap
= StringMap
<MemoryRegionInfo
>;
48 using FileInfoMap
= StringMap
<FileInfo
>;
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
);
58 bool isSymbolRegistered(StringRef Name
);
59 Expected
<MemoryRegionInfo
&> findSymbolInfo(StringRef SymbolName
,
62 SymbolInfoMap SymbolInfos
;
63 FileInfoMap FileInfos
;
64 uint64_t SizeBeforePruning
= 0;
65 uint64_t SizeAfterFixups
= 0;
68 Error
registerMachOStubsAndGOT(Session
&S
, jitlink::LinkGraph
&G
);
70 } // end namespace llvm
72 #endif // LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H