Look into local group on dlsym with RTLD_DEFAULT

Fix dlsym to look into local group when called with
  RTLD_DEFAULT and RTLD_NEXT.

Bug: 17512583
Change-Id: I541354e89539c712af2ea4ec751e546913027084
This commit is contained in:
Dmitriy Ivanov
2015-04-01 14:45:10 -07:00
parent ab7c79e22e
commit 76ac1acdac
6 changed files with 100 additions and 15 deletions

View File

@@ -101,16 +101,11 @@ void* dlsym(void* handle, const char* symbol) {
soinfo* found = nullptr;
ElfW(Sym)* sym = nullptr;
if (handle == RTLD_DEFAULT) {
sym = dlsym_linear_lookup(symbol, &found, nullptr);
} else if (handle == RTLD_NEXT) {
void* caller_addr = __builtin_return_address(0);
soinfo* si = find_containing_library(caller_addr);
void* caller_addr = __builtin_return_address(0);
soinfo* caller = find_containing_library(caller_addr);
sym = nullptr;
if (si && si->next) {
sym = dlsym_linear_lookup(symbol, &found, si->next);
}
if (handle == RTLD_DEFAULT || handle == RTLD_NEXT) {
sym = dlsym_linear_lookup(symbol, &found, caller, handle);
} else {
sym = dlsym_handle_lookup(reinterpret_cast<soinfo*>(handle), &found, symbol);
}