mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
cf3fe0c756
Moves all headers from Orc/RPC to Orc/Shared, and from the llvm::orc::rpc namespace into llvm::orc::shared. Also renames RPCTypeName to SerializationTypeName and Function to RPCFunction. In addition to being a more reasonable home for this code, this will make it easier for the upcoming Orc runtime to re-use the Serialization system for creating and parsing wrapper-function binary blobs.
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
|
|
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h"
|
|
#include "llvm/ExecutionEngine/Orc/Shared/FDRawByteChannel.h"
|
|
#include "llvm/Support/Debug.h"
|
|
#include "llvm/Support/DynamicLibrary.h"
|
|
#include "llvm/Support/Process.h"
|
|
#include <sstream>
|
|
|
|
#include "../RemoteJITUtils.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::orc;
|
|
using namespace llvm::sys;
|
|
|
|
#ifdef __x86_64__
|
|
typedef OrcX86_64_SysV HostOrcArch;
|
|
#else
|
|
typedef OrcGenericABI HostOrcArch;
|
|
#endif
|
|
|
|
ExitOnError ExitOnErr;
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
if (argc != 3) {
|
|
errs() << "Usage: " << argv[0] << " <input fd> <output fd>\n";
|
|
return 1;
|
|
}
|
|
|
|
ExitOnErr.setBanner(std::string(argv[0]) + ":");
|
|
|
|
int InFD;
|
|
int OutFD;
|
|
{
|
|
std::istringstream InFDStream(argv[1]), OutFDStream(argv[2]);
|
|
InFDStream >> InFD;
|
|
OutFDStream >> OutFD;
|
|
}
|
|
|
|
if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
|
|
errs() << "Error loading program symbols.\n";
|
|
return 1;
|
|
}
|
|
|
|
auto SymbolLookup = [](const std::string &Name) {
|
|
return RTDyldMemoryManager::getSymbolAddressInProcess(Name);
|
|
};
|
|
|
|
auto RegisterEHFrames = [](uint8_t *Addr, uint32_t Size) {
|
|
RTDyldMemoryManager::registerEHFramesInProcess(Addr, Size);
|
|
};
|
|
|
|
auto DeregisterEHFrames = [](uint8_t *Addr, uint32_t Size) {
|
|
RTDyldMemoryManager::deregisterEHFramesInProcess(Addr, Size);
|
|
};
|
|
|
|
shared::FDRawByteChannel Channel(InFD, OutFD);
|
|
typedef remote::OrcRemoteTargetServer<shared::FDRawByteChannel, HostOrcArch>
|
|
JITServer;
|
|
JITServer Server(Channel, SymbolLookup, RegisterEHFrames, DeregisterEHFrames);
|
|
|
|
while (!Server.receivedTerminate())
|
|
ExitOnErr(Server.handleOne());
|
|
|
|
close(InFD);
|
|
close(OutFD);
|
|
|
|
return 0;
|
|
}
|