bionic/linker: change lookup() to return soinfo, not base
This commit is contained in:
parent
6ed80c8814
commit
9ea64da6c5
@ -74,7 +74,7 @@ const char *dlerror(void)
|
|||||||
|
|
||||||
void *dlsym(void *handle, const char *symbol)
|
void *dlsym(void *handle, const char *symbol)
|
||||||
{
|
{
|
||||||
unsigned base;
|
soinfo *found;
|
||||||
Elf32_Sym *sym;
|
Elf32_Sym *sym;
|
||||||
unsigned bind;
|
unsigned bind;
|
||||||
|
|
||||||
@ -90,19 +90,19 @@ void *dlsym(void *handle, const char *symbol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(handle == RTLD_DEFAULT) {
|
if(handle == RTLD_DEFAULT) {
|
||||||
sym = lookup(symbol, &base);
|
sym = lookup(symbol, &found);
|
||||||
} else if(handle == RTLD_NEXT) {
|
} else if(handle == RTLD_NEXT) {
|
||||||
sym = lookup(symbol, &base);
|
sym = lookup(symbol, &found);
|
||||||
} else {
|
} else {
|
||||||
sym = lookup_in_library((soinfo*) handle, symbol);
|
found = (soinfo*)handle;
|
||||||
base = ((soinfo*) handle)->base;
|
sym = lookup_in_library(found, symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(likely(sym != 0)) {
|
if(likely(sym != 0)) {
|
||||||
bind = ELF32_ST_BIND(sym->st_info);
|
bind = ELF32_ST_BIND(sym->st_info);
|
||||||
|
|
||||||
if(likely((bind == STB_GLOBAL) && (sym->st_shndx != 0))) {
|
if(likely((bind == STB_GLOBAL) && (sym->st_shndx != 0))) {
|
||||||
unsigned ret = sym->st_value + base;
|
unsigned ret = sym->st_value + found->base;
|
||||||
pthread_mutex_unlock(&dl_lock);
|
pthread_mutex_unlock(&dl_lock);
|
||||||
return (void*)ret;
|
return (void*)ret;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ Elf32_Sym *lookup_in_library(soinfo *si, const char *name)
|
|||||||
|
|
||||||
/* This is used by dl_sym(). It performs a global symbol lookup.
|
/* This is used by dl_sym(). It performs a global symbol lookup.
|
||||||
*/
|
*/
|
||||||
Elf32_Sym *lookup(const char *name, unsigned *base)
|
Elf32_Sym *lookup(const char *name, soinfo **found)
|
||||||
{
|
{
|
||||||
unsigned elf_hash = 0;
|
unsigned elf_hash = 0;
|
||||||
Elf32_Sym *s = NULL;
|
Elf32_Sym *s = NULL;
|
||||||
@ -494,7 +494,7 @@ Elf32_Sym *lookup(const char *name, unsigned *base)
|
|||||||
continue;
|
continue;
|
||||||
s = _do_lookup_in_so(si, name, &elf_hash);
|
s = _do_lookup_in_so(si, name, &elf_hash);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
*base = si->base;
|
*found = si;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ extern soinfo libdl_info;
|
|||||||
soinfo *find_library(const char *name);
|
soinfo *find_library(const char *name);
|
||||||
unsigned unload_library(soinfo *si);
|
unsigned unload_library(soinfo *si);
|
||||||
Elf32_Sym *lookup_in_library(soinfo *si, const char *name);
|
Elf32_Sym *lookup_in_library(soinfo *si, const char *name);
|
||||||
Elf32_Sym *lookup(const char *name, unsigned *base);
|
Elf32_Sym *lookup(const char *name, soinfo **found);
|
||||||
const char *linker_get_error(void);
|
const char *linker_get_error(void);
|
||||||
|
|
||||||
#ifdef ANDROID_ARM_LINKER
|
#ifdef ANDROID_ARM_LINKER
|
||||||
|
Loading…
x
Reference in New Issue
Block a user