summaryrefslogtreecommitdiff
path: root/src/linker
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-22 18:40:15 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-22 18:46:36 +0200
commitc4f2f8449ad09301e5725f69b7374d958cc5dff8 (patch)
tree084c8e916e09cd0cbd16bd6732b0fbff217fc81b /src/linker
parent952720c8def83d62bc0d328c2cc46ead8254703d (diff)
refactor commit
Diffstat (limited to 'src/linker')
-rw-r--r--src/linker/linker.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/linker/linker.c b/src/linker/linker.c
index e5e1095..0927164 100644
--- a/src/linker/linker.c
+++ b/src/linker/linker.c
@@ -119,7 +119,7 @@ static const char *apkenv_ldpreload_names[LDPRELOAD_MAX + 1];
static soinfo *apkenv_preloads[LDPRELOAD_MAX + 1];
#if LINKER_DEBUG
-int apkenv_debug_verbosity = 5;
+int apkenv_debug_verbosity = 0;
#endif
static int apkenv_pid;
@@ -1133,6 +1133,10 @@ apkenv_load_library(const char *name)
Elf32_Ehdr *hdr;
if(fd == -1) {
+ if (dlopen(name, RTLD_NOW | RTLD_GLOBAL)) {
+ DEBUG("Loaded %s with glibc dlopen\n", name);
+ return NULL;
+ }
#if !LINKER_DEBUG
if (!is_lib_optional(name))
#endif
@@ -1365,12 +1369,9 @@ static int apkenv_reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
memcpy(wrap_sym_name + 7, sym_name, MIN(sizeof(wrap_sym_name) - 7, strlen(sym_name)));
sym_addr = 0;
- if (!strcmp(sym_name, "dl_iterate_phdr")) {
- // FIXME: hack, move to libc.so
- sym_addr = bionic_dl_iterate_phdr;
- } else if ((sym_addr = dlsym(RTLD_DEFAULT, wrap_sym_name))) {
+ 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 ((sym_addr = dlsym(RTLD_DEFAULT, sym_name))) {
+ } else if ((sym_addr = (intptr_t)dlsym(RTLD_DEFAULT, sym_name))) {
LINKER_DEBUG_PRINTF("%s hooked symbol %s to %x\n", si->name, sym_name, sym_addr);
}
#if 0
@@ -1762,8 +1763,8 @@ static int apkenv_nullify_closed_stdio (void)
static void apkenv_wrap_function(void *sym_addr, char *sym_name, int is_thumb, soinfo *si)
{
- void *hook = NULL;
#ifdef APKENV_LATEHOOKS
+ void *hook = NULL;
if((hook = apkenv_get_hooked_symbol(sym_name, 0)) != NULL)
{
// if we have a hook redirect the call to that by overwriting
@@ -2068,13 +2069,8 @@ static int apkenv_link_image(soinfo *si, unsigned wr_offset)
if(d[0] == DT_NEEDED){
DEBUG("%5d %s needs %s\n", apkenv_pid, si->name, si->strtab + d[1]);
soinfo *lsi = NULL;
-#if 1
// if (get_builtin_lib_handle(si->strtab + d[1]) == NULL)
lsi = apkenv_find_library(si->strtab + d[1]);
- if (!lsi && dlopen(si->strtab + d[1], RTLD_NOW | RTLD_GLOBAL)) {
- DEBUG("Loaded %s with glibc dlopen\n", si->strtab + d[1]);
- }
-#endif
if(lsi == 0) {
/**
* XXX Dirty Hack Alarm --thp XXX