#include #include #ifdef __linux__ #include #endif namespace pslang::jit { compiled_module make_host_executable(compiled_module module) { #ifdef __linux__ if (module.abi != abi::itanium) throw std::runtime_error("Abi mismatch"); auto ptr = (std::uint8_t *)mmap(nullptr, module.memory.size, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); auto shared_ptr = std::shared_ptr(ptr, [size = module.memory.size](std::uint8_t * ptr){ munmap(ptr, size); }); return compiled_module { .memory = blob(shared_ptr, module.memory.size), .symbol_table = std::move(module.symbol_table), .entry_point = module.entry_point, .abi = module.abi, }; #else throw std::runtime_error("Host-executable modules are not supported for this platform"); #endif } }