copy dlopen/dlsym method from mac branch