Add a check that we've made it into the C runtime when doing dlopen().

This should give us a more informative failure mode than the one
mentioned in the README.
macos/v1.5.9
Eric Anholt 11 years ago
parent 03e9537331
commit 10c611a3f1
  1. 17
      src/dispatch_common.c

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

Loading…
Cancel
Save