26 #if defined(__linux__)
42 #define LIB_DEFAULT ((void *) 0)
51 void*
const m_lib_default;
52 void*
const m_lib_next;
54 int const m_flag_lazy;
56 int const m_flag_local;
57 int const m_flag_global;
61 int const flag_lazy,
int const flag_now,
int const flag_local,
int const flag_global)
62 : m_lib_default(lib_default), m_lib_next(lib_next),
63 m_flag_lazy(flag_lazy), m_flag_now(flag_now), m_flag_local(flag_local), m_flag_global(flag_global)
70 return ::dlopen((
char *) pathname.c_str(), m_flag_lazy | m_flag_global);
74 return ::dlopen((
char *) pathname.c_str(), m_flag_lazy | m_flag_local);
78 if(
nullptr != handle && symbolName.length() > 0 ) {
79 symhandle_t addr = ::dlsym(handle, symbolName.c_str());
80 if(
nullptr != addr ) {
82 if( 0 != ::dladdr(addr, &info) ) {
83 return info.dli_fname;
93 return ::dlsym(m_lib_default, symbolName.c_str());
97 if(
nullptr != handle ) {
98 return ::dlsym(handle, symbolName.c_str());
105 if(
nullptr != handle ) {
111 const char * res = ::dlerror();
112 if(
nullptr != res ) {
113 return std::string(res);
115 return std::string();
125 constexpr static void*
const LIB_DEFAULT =
nullptr;
126 inline static void*
const LIB_NEXT =
reinterpret_cast<void *
>( -1l );
128 constexpr static int const FLAG_LAZY = 0x00001;
129 constexpr static int const FLAG_NOW = 0x00002;
130 constexpr static int const FLAG_LOCAL = 0x00000;
131 constexpr static int const FLAG_GLOBAL = 0x00100;
135 :
UnixDynamicLinker(LIB_DEFAULT, LIB_NEXT, FLAG_LAZY, FLAG_NOW, FLAG_LOCAL, FLAG_GLOBAL) {}
143 inline static void*
const LIB_DEFAULT =
reinterpret_cast<void *
>( -2l );
144 inline static void*
const LIB_NEXT =
reinterpret_cast<void *
>( -1l );
146 constexpr static int const FLAG_LAZY = 0x00001;
147 constexpr static int const FLAG_NOW = 0x00002;
148 constexpr static int const FLAG_LOCAL = 0x00004;
149 constexpr static int const FLAG_GLOBAL = 0x00008;
153 :
UnixDynamicLinker(LIB_DEFAULT, LIB_NEXT, FLAG_LAZY, FLAG_NOW, FLAG_LOCAL, FLAG_GLOBAL) {}
163 inline static void*
const LIB_DEFAULT =
reinterpret_cast<void *
>( 0xfffffffful );
164 inline static void*
const LIB_NEXT =
reinterpret_cast<void *
>( 0xfffffffeul );
166 constexpr static int const FLAG_LAZY = 0x00001;
167 constexpr static int const FLAG_NOW = 0x00000;
168 constexpr static int const FLAG_LOCAL = 0x00000;
169 constexpr static int const FLAG_GLOBAL = 0x00002;
174 :
UnixDynamicLinker(LIB_DEFAULT, LIB_NEXT, FLAG_LAZY, FLAG_NOW, FLAG_LOCAL, FLAG_GLOBAL) {}
Low level secure dynamic linker access.
void * symhandle_t
symbol handle within a library
void * libhandle_t
library handle
Bionic 32bit (Android) specialization of UnixDynamicLinkerImpl with non-POSIX flags and mode values.
Bionic32DynamicLinker() noexcept
Darwin (MacOSX/iOS) specialization of UnixDynamicLinkerImpl with non-POSIX flags and mode values.
DarwinDynamicLinker() noexcept
POSIX specialization of UnixDynamicLinkerImpl with POSIX flags and mode values.
PosixDynamicLinker() noexcept
symhandle_t lookupSymbolLocalImpl(libhandle_t handle, const std::string &symbolName) noexcept override
void closeLibraryImpl(libhandle_t handle) noexcept override
UnixDynamicLinker(void *const lib_default, void *const lib_next, int const flag_lazy, int const flag_now, int const flag_local, int const flag_global)
std::string getLastErrorImpl() noexcept override
libhandle_t openLibraryLocalImpl(const std::string &pathname) noexcept override
symhandle_t lookupSymbolGlobalImpl(const std::string &symbolName) noexcept override
const char * lookupLibraryPathnameImpl(libhandle_t handle, const std::string &symbolName) noexcept override
libhandle_t openLibraryGlobalImpl(const std::string &pathname) noexcept override
constexpr bool is_darwin() noexcept
Evaluates true if platform os_type::native contains os_type::Darwin.
constexpr bool is_android() noexcept
Evaluates true if platform os_type::native contains os_type::Android.
constexpr size_t pointer_bit_size() noexcept
Returns the compile time pointer architecture size in bits.
Author: Sven Gothel sgothel@jausoft.com Copyright (c) 2024 Gothel Software e.K.