1 #include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
2 #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h"
3 #include "llvm/Support/Debug.h"
4 #include "llvm/Support/DynamicLibrary.h"
5 #include "llvm/Support/Process.h"
8 #include "../RemoteJITUtils.h"
11 using namespace llvm::orc
;
12 using namespace llvm::sys
;
15 typedef OrcX86_64_SysV HostOrcArch
;
17 typedef OrcGenericABI HostOrcArch
;
20 ExitOnError ExitOnErr
;
22 int main(int argc
, char *argv
[]) {
25 errs() << "Usage: " << argv
[0] << " <input fd> <output fd>\n";
29 ExitOnErr
.setBanner(std::string(argv
[0]) + ":");
34 std::istringstream
InFDStream(argv
[1]), OutFDStream(argv
[2]);
39 if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
40 errs() << "Error loading program symbols.\n";
44 auto SymbolLookup
= [](const std::string
&Name
) {
45 return RTDyldMemoryManager::getSymbolAddressInProcess(Name
);
48 auto RegisterEHFrames
= [](uint8_t *Addr
, uint32_t Size
) {
49 RTDyldMemoryManager::registerEHFramesInProcess(Addr
, Size
);
52 auto DeregisterEHFrames
= [](uint8_t *Addr
, uint32_t Size
) {
53 RTDyldMemoryManager::deregisterEHFramesInProcess(Addr
, Size
);
56 FDRawChannel
Channel(InFD
, OutFD
);
57 typedef remote::OrcRemoteTargetServer
<FDRawChannel
, HostOrcArch
> JITServer
;
58 JITServer
Server(Channel
, SymbolLookup
, RegisterEHFrames
, DeregisterEHFrames
);
60 while (!Server
.receivedTerminate())
61 ExitOnErr(Server
.handleOne());