Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546e.

Bug: 17107521
(cherry picked from commit 9419420919)

Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
This commit is contained in:
Dmitriy Ivanov
2014-08-18 15:08:51 -07:00
parent 0baf2ca34c
commit 02aa70589d
8 changed files with 31 additions and 163 deletions

View File

@@ -100,22 +100,29 @@ void* dlsym(void* handle, const char* symbol) {
soinfo* found = NULL;
ElfW(Sym)* sym = NULL;
void* caller_addr = __builtin_return_address(0);
soinfo* caller_si = find_containing_library(caller_addr);
if (handle == RTLD_DEFAULT) {
sym = dlsym_linear_lookup(symbol, &found, NULL, caller_si);
sym = dlsym_linear_lookup(symbol, &found, NULL);
} else if (handle == RTLD_NEXT) {
void* caller_addr = __builtin_return_address(0);
soinfo* si = find_containing_library(caller_addr);
sym = NULL;
if (caller_si && caller_si->next) {
sym = dlsym_linear_lookup(symbol, &found, caller_si->next, caller_si);
if (si && si->next) {
sym = dlsym_linear_lookup(symbol, &found, si->next);
}
} else {
sym = dlsym_handle_lookup(reinterpret_cast<soinfo*>(handle), &found, symbol, caller_si);
sym = dlsym_handle_lookup(reinterpret_cast<soinfo*>(handle), &found, symbol);
}
if (sym != NULL && sym->st_shndx != 0) {
return reinterpret_cast<void*>(sym->st_value + found->load_bias);
if (sym != NULL) {
unsigned bind = ELF_ST_BIND(sym->st_info);
if ((bind == STB_GLOBAL || bind == STB_WEAK) && sym->st_shndx != 0) {
return reinterpret_cast<void*>(sym->st_value + found->load_bias);
}
__bionic_format_dlerror("symbol found but not global", symbol);
return NULL;
} else {
__bionic_format_dlerror("undefined symbol", symbol);
return NULL;