|
|
@ -157,12 +157,29 @@ static struct api api = { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
#ifndef _WIN32 |
|
|
|
|
|
|
|
static bool library_initialized; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
library_init(void) __attribute__((constructor)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
library_init(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
library_initialized = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) |
|
|
|
get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (*handle) |
|
|
|
if (*handle) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!library_initialized) { |
|
|
|
|
|
|
|
fprintf(stderr, |
|
|
|
|
|
|
|
"Attempting to dlopen() while in the dynamic linker.\n"); |
|
|
|
|
|
|
|
abort(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&api.mutex); |
|
|
|
pthread_mutex_lock(&api.mutex); |
|
|
|
if (!*handle) { |
|
|
|
if (!*handle) { |
|
|
|
*handle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL); |
|
|
|
*handle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL); |
|
|
|