summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-11-18 16:35:29 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-11-18 16:35:29 +0200
commitef5f90bc25cdfa958702fb8d03a49647b899dee7 (patch)
tree080d47085954af6fd475b196888fb222f1d732fc /src
parent9a59d14d0a457a714dc9421a1f9bd28b6ae3a86f (diff)
linker fixes
Diffstat (limited to 'src')
-rw-r--r--src/linker/dlfcn.c3
-rw-r--r--src/linker/linker.c20
2 files changed, 9 insertions, 14 deletions
diff --git a/src/linker/dlfcn.c b/src/linker/dlfcn.c
index 22d212a..509e0f9 100644
--- a/src/linker/dlfcn.c
+++ b/src/linker/dlfcn.c
@@ -70,6 +70,9 @@ void *bionic_dlopen(const char *filename, int flag)
ret = apkenv_find_library(filename, false);
if (unlikely(ret == NULL)) {
+ if (!(flag & (RTLD_LAZY | RTLD_NOW)))
+ flag |= RTLD_NOW;
+
if (!(ret = dlopen(filename, flag)))
set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY);
} else {
diff --git a/src/linker/linker.c b/src/linker/linker.c
index e4e9f8a..66fc593 100644
--- a/src/linker/linker.c
+++ b/src/linker/linker.c
@@ -394,7 +394,7 @@ static Elf32_Sym *apkenv__elf_lookup(soinfo *si, unsigned hash, const char *name
unsigned n;
TRACE_TYPE(LOOKUP, "%5d SEARCH %s in %s@0x%08x %08x %d\n", apkenv_pid,
- name, si->name, si->base, hash, hash % si->nbucket);
+ name, si->name, si->base, hash, hash % (si->nbucket ? si->nbucket : 1));
if (si->nbucket == 0) {
return NULL;
}
@@ -1374,28 +1374,20 @@ static int apkenv_reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
if ((sym_addr = (intptr_t)dlsym(RTLD_DEFAULT, wrap_sym_name))) {
LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, wrap_sym_name, sym_addr);
+ } else if ((s = apkenv__do_lookup(si, sym_name, &base))) {
+ // normal symbol
} else if ((sym_addr = (intptr_t)dlsym(RTLD_DEFAULT, sym_name))) {
if (strstr(sym_name, "pthread_"))
fprintf(stderr, "symbol may need to be wrapped: %s\n", sym_name);
LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, sym_name, sym_addr);
}
-#if 0
- if ((sym_addr = (unsigned)apkenv_get_hooked_symbol(sym_name, 1)) != 0) {
- LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, sym_name, sym_addr);
- }
-#endif
- else
- {
- s = apkenv__do_lookup(si, sym_name, &base);
- }
- if(sym_addr != 0)
- {
+
+ if (sym_addr != 0) {
Dl_info info;
ElfW(Sym) *extra;
if (dladdr1((void*)sym_addr, &info, (void**) &extra, RTLD_DL_SYMENT) && (!extra || ELF32_ST_TYPE(extra->st_info) == STT_FUNC))
sym_addr = (unsigned)wrapper_create(sym_name, (void*)sym_addr);
- } else
- if(s == NULL) {
+ } else if (s == NULL) {
/* We only allow an undefined symbol if this is a weak
reference.. */
s = &symtab[sym];