Fix RTLD_NEXT/DEFAULT lookup
RTLD_NEXT/DEFAULT lookup should not skip handle lookup
in the case when the load group is RTLD_GLOBAL.
Note that there is a difference between load group is local group.
The local group includes externally referenced libraries where
the load group does not. The external reference in this context is a
DT_NEEDED library that belongs to a previously loaded group.
Bug: http://b/72237367
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I8997cc961c13a5396f1756161798b45ed1cab16c
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index fb05cd3..c40a35b 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1123,7 +1123,7 @@
// Check that RTLD_NEXT of a libc symbol works in dlopened library
TEST(dlfcn, rtld_next_from_library) {
- void* library_with_fclose = dlopen("libtest_check_rtld_next_from_library.so", RTLD_NOW);
+ void* library_with_fclose = dlopen("libtest_check_rtld_next_from_library.so", RTLD_NOW | RTLD_GLOBAL);
ASSERT_TRUE(library_with_fclose != nullptr) << dlerror();
void* expected_addr = dlsym(RTLD_DEFAULT, "fclose");
ASSERT_TRUE(expected_addr != nullptr) << dlerror();