#include "elfnix_platform.h"
#include "common.h"
#include "compiler.h"
#include "error.h"
#include "wrapper_function_utils.h"
#include <algorithm>
#include <map>
#include <mutex>
#include <sstream>
#include <string_view>
#include <unordered_map>
#include <vector>
usingnamespace__orc_rt;
usingnamespace__orc_rt::elfnix;
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_get_initializers_tag)
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_get_deinitializers_tag)
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_symbol_lookup_tag)
extern "C" void __register_frame(const void *);
extern "C" void __deregister_frame(const void *);
extern "C" void
__unw_add_dynamic_eh_frame_section(const void *) ORC_RT_WEAK_IMPORT;
extern "C" void
__unw_remove_dynamic_eh_frame_section(const void *) ORC_RT_WEAK_IMPORT;
namespace {
Error validatePointerSectionExtent(const char *SectionName,
const ExecutorAddrRange &SE) { … }
Error runInitArray(const std::vector<ExecutorAddrRange> &InitArraySections,
const ELFNixJITDylibInitializers &MOJDIs) { … }
struct TLSInfoEntry { … };
struct TLSDescriptor { … };
class ELFNixPlatformRuntimeState { … };
ELFNixPlatformRuntimeState *ELFNixPlatformRuntimeState::MOPS = …;
void ELFNixPlatformRuntimeState::initialize(void *DSOHandle) { … }
ELFNixPlatformRuntimeState &ELFNixPlatformRuntimeState::get() { … }
void ELFNixPlatformRuntimeState::destroy() { … }
ELFNixPlatformRuntimeState::ELFNixPlatformRuntimeState(void *DSOHandle)
: … { … }
Error ELFNixPlatformRuntimeState::registerObjectSections(
ELFNixPerObjectSectionsToRegister POSR) { … }
Error ELFNixPlatformRuntimeState::deregisterObjectSections(
ELFNixPerObjectSectionsToRegister POSR) { … }
const char *ELFNixPlatformRuntimeState::dlerror() { … }
void *ELFNixPlatformRuntimeState::dlopen(std::string_view Path, int Mode) { … }
int ELFNixPlatformRuntimeState::dlclose(void *DSOHandle) { … }
void *ELFNixPlatformRuntimeState::dlsym(void *DSOHandle,
std::string_view Symbol) { … }
int ELFNixPlatformRuntimeState::registerAtExit(void (*F)(void *), void *Arg,
void *DSOHandle) { … }
void ELFNixPlatformRuntimeState::runAtExits(void *DSOHandle) { … }
Expected<std::pair<const char *, size_t>>
ELFNixPlatformRuntimeState::getThreadDataSectionFor(const char *ThreadData) { … }
ELFNixPlatformRuntimeState::PerJITDylibState *
ELFNixPlatformRuntimeState::getJITDylibStateByHeaderAddr(void *DSOHandle) { … }
ELFNixPlatformRuntimeState::PerJITDylibState *
ELFNixPlatformRuntimeState::getJITDylibStateByName(std::string_view Name) { … }
ELFNixPlatformRuntimeState::PerJITDylibState &
ELFNixPlatformRuntimeState::getOrCreateJITDylibState(
ELFNixJITDylibInitializers &MOJDIs) { … }
Error ELFNixPlatformRuntimeState::registerThreadDataSection(
span<const char> ThreadDataSection) { … }
Expected<ExecutorAddr>
ELFNixPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle,
std::string_view Sym) { … }
Expected<ELFNixJITDylibInitializerSequence>
ELFNixPlatformRuntimeState::getJITDylibInitializersByName(
std::string_view Path) { … }
Expected<void *>
ELFNixPlatformRuntimeState::dlopenInitialize(std::string_view Path, int Mode) { … }
long getPriority(const std::string &name) { … }
Error ELFNixPlatformRuntimeState::initializeJITDylib(
ELFNixJITDylibInitializers &MOJDIs) { … }
class ELFNixPlatformRuntimeTLVManager { … };
void *ELFNixPlatformRuntimeTLVManager::getInstance(const char *ThreadData) { … }
void destroyELFNixTLVMgr(void *ELFNixTLVMgr) { … }
}
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_elfnix_platform_bootstrap(char *ArgData, size_t ArgSize) { … }
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_elfnix_platform_shutdown(char *ArgData, size_t ArgSize) { … }
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_elfnix_register_object_sections(char *ArgData, size_t ArgSize) { … }
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_elfnix_deregister_object_sections(char *ArgData, size_t ArgSize) { … }
ORC_RT_INTERFACE void *__orc_rt_elfnix_tls_get_addr_impl(TLSInfoEntry *D) { … }
ORC_RT_INTERFACE ptrdiff_t ___orc_rt_elfnix_tlsdesc_resolver_impl(
TLSDescriptor *D, const char *ThreadPointer) { … }
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_elfnix_create_pthread_key(char *ArgData, size_t ArgSize) { … }
int __orc_rt_elfnix_cxa_atexit(void (*func)(void *), void *arg,
void *dso_handle) { … }
int __orc_rt_elfnix_atexit(void (*func)(void *)) { … }
void __orc_rt_elfnix_cxa_finalize(void *dso_handle) { … }
const char *__orc_rt_elfnix_jit_dlerror() { … }
void *__orc_rt_elfnix_jit_dlopen(const char *path, int mode) { … }
int __orc_rt_elfnix_jit_dlclose(void *dso_handle) { … }
void *__orc_rt_elfnix_jit_dlsym(void *dso_handle, const char *symbol) { … }
ORC_RT_INTERFACE int64_t __orc_rt_elfnix_run_program(
const char *JITDylibName, const char *EntrySymbolName, int argc,
char *argv[]) { … }