Add RTLD_NOLOAD support and some related changes.
* Aligned RTLD_ values with glibc for lp64
* dlopen supports RTLD_NOLOAD flag
* soinfo_unload calls find_library(.., RTLD_NOLOAD)
instead of naive find_loaded_library_by_name()
* dlopen changed to add child to caller soinfo instead
of somain.
Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: I1a65f2c34f3e0edc6d2c41a2e408b58195feb640
diff --git a/tests/Android.mk b/tests/Android.mk
index 9a17c10..51f10ca 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -267,6 +267,18 @@
include $(LOCAL_PATH)/Android.build.mk
# -----------------------------------------------------------------------------
+# Library used by dlfcn tests
+# -----------------------------------------------------------------------------
+libtest_simple_src_files := \
+ dlopen_testlib_simple.cpp
+
+module := libtest_simple
+build_type := target
+build_target := SHARED_LIBRARY
+include $(LOCAL_PATH)/Android.build.mk
+
+
+# -----------------------------------------------------------------------------
# Library used by atexit tests
# -----------------------------------------------------------------------------
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 3b3c0f6..434e38f 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -50,6 +50,18 @@
ASSERT_EQ(0, dlclose(self));
}
+TEST(dlfcn, dlopen_noload) {
+ void* handle = dlopen("libtest_simple.so", RTLD_NOW | RTLD_NOLOAD);
+ ASSERT_TRUE(handle == NULL);
+ handle = dlopen("libtest_simple.so", RTLD_NOW);
+ void* handle2 = dlopen("libtest_simple.so", RTLD_NOW | RTLD_NOLOAD);
+ ASSERT_TRUE(handle != NULL);
+ ASSERT_TRUE(handle2 != NULL);
+ ASSERT_TRUE(handle == handle2);
+ ASSERT_EQ(0, dlclose(handle));
+ ASSERT_EQ(0, dlclose(handle2));
+}
+
TEST(dlfcn, dlopen_failure) {
void* self = dlopen("/does/not/exist", RTLD_NOW);
ASSERT_TRUE(self == NULL);
diff --git a/tests/dlopen_testlib_simple.cpp b/tests/dlopen_testlib_simple.cpp
new file mode 100644
index 0000000..afe54b4
--- /dev/null
+++ b/tests/dlopen_testlib_simple.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+uint32_t dlopen_testlib_taxicab_number = 1729;
+
+bool dlopen_testlib_simple_func() {
+ return true;
+}