89 lines · c
1//===- elfnix_platform.h ----------------------------------------*- C++ -*-===//2//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-exception6//7//===----------------------------------------------------------------------===//8//9// ORC Runtime support for dynamic loading features on ELF-based platforms.10//11//===----------------------------------------------------------------------===//12 13#ifndef ORC_RT_ELFNIX_PLATFORM_H14#define ORC_RT_ELFNIX_PLATFORM_H15 16#include "common.h"17#include "executor_address.h"18 19// Atexit functions.20ORC_RT_INTERFACE int __orc_rt_elfnix_cxa_atexit(void (*func)(void *), void *arg,21 void *dso_handle);22ORC_RT_INTERFACE int __orc_rt_elfnix_atexit(void (*func)(void *));23ORC_RT_INTERFACE void __orc_rt_elfnix_cxa_finalize(void *dso_handle);24 25// dlfcn functions.26ORC_RT_INTERFACE const char *__orc_rt_elfnix_jit_dlerror();27ORC_RT_INTERFACE void *__orc_rt_elfnix_jit_dlopen(const char *path, int mode);28ORC_RT_INTERFACE int __orc_rt_elfnix_jit_dlupdate(void *dso_handle);29ORC_RT_INTERFACE int __orc_rt_elfnix_jit_dlclose(void *dso_handle);30ORC_RT_INTERFACE void *__orc_rt_elfnix_jit_dlsym(void *dso_handle,31 const char *symbol);32 33namespace orc_rt {34namespace elfnix {35 36struct ELFNixPerObjectSectionsToRegister {37 ExecutorAddrRange EHFrameSection;38 ExecutorAddrRange ThreadDataSection;39};40 41using ELFNixJITDylibDepInfo = std::vector<ExecutorAddr>;42 43using ELFNixJITDylibDepInfoMap =44 std::unordered_map<ExecutorAddr, ELFNixJITDylibDepInfo>;45 46enum dlopen_mode : int {47 ORC_RT_RTLD_LAZY = 0x1,48 ORC_RT_RTLD_NOW = 0x2,49 ORC_RT_RTLD_LOCAL = 0x4,50 ORC_RT_RTLD_GLOBAL = 0x851};52 53} // namespace elfnix54 55using SPSELFNixPerObjectSectionsToRegister =56 SPSTuple<SPSExecutorAddrRange, SPSExecutorAddrRange>;57 58template <>59class SPSSerializationTraits<SPSELFNixPerObjectSectionsToRegister,60 elfnix::ELFNixPerObjectSectionsToRegister> {61 62public:63 static size_t size(const elfnix::ELFNixPerObjectSectionsToRegister &MOPOSR) {64 return SPSELFNixPerObjectSectionsToRegister::AsArgList::size(65 MOPOSR.EHFrameSection, MOPOSR.ThreadDataSection);66 }67 68 static bool69 serialize(SPSOutputBuffer &OB,70 const elfnix::ELFNixPerObjectSectionsToRegister &MOPOSR) {71 return SPSELFNixPerObjectSectionsToRegister::AsArgList::serialize(72 OB, MOPOSR.EHFrameSection, MOPOSR.ThreadDataSection);73 }74 75 static bool deserialize(SPSInputBuffer &IB,76 elfnix::ELFNixPerObjectSectionsToRegister &MOPOSR) {77 return SPSELFNixPerObjectSectionsToRegister::AsArgList::deserialize(78 IB, MOPOSR.EHFrameSection, MOPOSR.ThreadDataSection);79 }80};81 82using SPSELFNixJITDylibDepInfo = SPSSequence<SPSExecutorAddr>;83using SPSELFNixJITDylibDepInfoMap =84 SPSSequence<SPSTuple<SPSExecutorAddr, SPSELFNixJITDylibDepInfo>>;85 86} // namespace orc_rt87 88#endif // ORC_RT_ELFNIX_PLATFORM_H89