diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-03-10 17:20:28 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-03-10 17:20:28 +0200 |
commit | b8be671580f22479d534e188aec9c81a01a3d5f8 (patch) | |
tree | fdc4ab3b4f78a6378b302bc33c9740feb41a1b40 /src/linker/dlfcn.c | |
parent | dcc9c06d34aff4853a594dc4029b7594d3f20d1e (diff) |
linker: Refactor glibc dlopen hacks
Allows us to return "valid" pointer when bionic program calls dlopen.
Diffstat (limited to 'src/linker/dlfcn.c')
-rw-r--r-- | src/linker/dlfcn.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/linker/dlfcn.c b/src/linker/dlfcn.c index 38fc215..22d212a 100644 --- a/src/linker/dlfcn.c +++ b/src/linker/dlfcn.c @@ -67,10 +67,11 @@ void *bionic_dlopen(const char *filename, int flag) verbose("%s (%d)", filename, flag); soinfo *ret; pthread_mutex_lock(&apkenv_dl_lock); - ret = apkenv_find_library(filename); + ret = apkenv_find_library(filename, false); if (unlikely(ret == NULL)) { - set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY); + if (!(ret = dlopen(filename, flag))) + set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY); } else { apkenv_call_constructors_recursive(ret); ret->refcount++; @@ -102,12 +103,6 @@ void *bionic_dlsym(void *handle, const char *symbol) pthread_mutex_lock(&apkenv_dl_lock); -#if 0 - if(unlikely(handle == 0)) { - set_dlerror(DL_ERR_INVALID_LIBRARY_HANDLE); - goto err; - } -#endif if(unlikely(symbol == 0)) { set_dlerror(DL_ERR_BAD_SYMBOL_NAME); goto err; @@ -127,6 +122,11 @@ void *bionic_dlsym(void *handle, const char *symbol) } } + if(unlikely(handle == 0)) { + set_dlerror(DL_ERR_INVALID_LIBRARY_HANDLE); + goto err; + } + if(handle == RTLD_DEFAULT) { sym = apkenv_lookup(symbol, &found, NULL); } else if(handle == RTLD_NEXT) { |