Revert "Add support for protected local symbol lookup."
This reverts commit d97e9f546ea195686a78e539315b273393609b9e.
Bug: 17107521
(cherry picked from commit 9419420919ea846bbad5510850c7aaec95021648)
Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 8ebf357..5d6db8e 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -100,22 +100,29 @@
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;