diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2014-07-29 14:21:45 -0700 |
---|---|---|
committer | Dmitriy Ivanov <dimitry@google.com> | 2014-09-03 15:06:14 -0700 |
commit | a3ad450a2e3fb6b3fe359683b247eba20896f646 (patch) | |
tree | 46d55ca77bbe24d4834444ed21aa146bf6750e37 /tests/libs | |
parent | ec95a9cf11f7c4d2211c61da7ce05262a54409d1 (diff) | |
download | bionic-a3ad450a2e3fb6b3fe359683b247eba20896f646.zip bionic-a3ad450a2e3fb6b3fe359683b247eba20896f646.tar.gz bionic-a3ad450a2e3fb6b3fe359683b247eba20896f646.tar.bz2 |
Load libraries in breadth-first order
This patch fixes the problem with symbol search order
for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
and ld_preloads in correct order.
Bug: https://code.google.com/p/android/issues/detail?id=74255
Change-Id: I4cf84c70dbaabe99310230dfda12385ae5401859
Diffstat (limited to 'tests/libs')
-rw-r--r-- | tests/libs/Android.mk | 154 | ||||
-rw-r--r-- | tests/libs/dlopen_testlib_answer.cpp | 25 |
2 files changed, 179 insertions, 0 deletions
diff --git a/tests/libs/Android.mk b/tests/libs/Android.mk index b1cc836..2ceb15b 100644 --- a/tests/libs/Android.mk +++ b/tests/libs/Android.mk @@ -103,6 +103,160 @@ build_target := SHARED_LIBRARY include $(TEST_PATH)/Android.build.mk # ----------------------------------------------------------------------------- +# Libraries used by dlfcn tests to verify correct load order: +# libtest_check_order_2_right.so +# ----------------------------------------------------------------------------- +libtest_check_order_2_right_src_files := \ + dlopen_testlib_answer.cpp + +libtest_check_order_2_right_cflags := -D__ANSWER=42 +module := libtest_check_order_2_right +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order_a.so +# ----------------------------------------------------------------------------- +libtest_check_order_a_src_files := \ + dlopen_testlib_answer.cpp + +libtest_check_order_a_cflags := -D__ANSWER=1 +module := libtest_check_order_a +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order_b.so +# ----------------------------------------------------------------------------- +libtest_check_order_b_src_files := \ + dlopen_testlib_answer.cpp + +libtest_check_order_b_cflags := -D__ANSWER=2 -D__ANSWER2=43 +module := libtest_check_order_b +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order_c.so +# ----------------------------------------------------------------------------- +libtest_check_order_3_c_src_files := \ + dlopen_testlib_answer.cpp + +libtest_check_order_3_c_cflags := -D__ANSWER=3 +module := libtest_check_order_3_c +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order_d.so +# ----------------------------------------------------------------------------- +libtest_check_order_d_src_files := \ + dlopen_testlib_answer.cpp + +libtest_check_order_d_shared_libraries := libtest_check_order_b +libtest_check_order_d_cflags := -D__ANSWER=4 -D__ANSWER2=4 +module := libtest_check_order_d +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order_left.so +# ----------------------------------------------------------------------------- +libtest_check_order_1_left_src_files := \ + empty.cpp + +libtest_check_order_1_left_shared_libraries := libtest_check_order_a libtest_check_order_b + +module := libtest_check_order_1_left +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_check_order.so +# ----------------------------------------------------------------------------- +libtest_check_order_src_files := \ + empty.cpp + +libtest_check_order_shared_libraries := libtest_check_order_1_left \ + libtest_check_order_2_right libtest_check_order_3_c + +module := libtest_check_order +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# Library with dependency loop used by dlfcn tests +# +# libtest_with_dependency_loop -> a -> b -> c -> a +# ----------------------------------------------------------------------------- +libtest_with_dependency_loop_src_files := empty.cpp + +libtest_with_dependency_loop_shared_libraries := \ + libtest_with_dependency_loop_a + +module := libtest_with_dependency_loop +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_with_dependency_loop_a.so +# ----------------------------------------------------------------------------- +libtest_with_dependency_loop_a_src_files := empty.cpp + +libtest_with_dependency_loop_a_shared_libraries := \ + libtest_with_dependency_loop_b_tmp + +module := libtest_with_dependency_loop_a +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_with_dependency_loop_b.so +# +# this is temporary placeholder - will be removed +# ----------------------------------------------------------------------------- +libtest_with_dependency_loop_b_tmp_src_files := empty.cpp +libtest_with_dependency_loop_b_tmp_ldflags := -Wl,-soname=libtest_with_dependency_loop_b.so + +module := libtest_with_dependency_loop_b_tmp +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_with_dependency_loop_b.so +# ----------------------------------------------------------------------------- +libtest_with_dependency_loop_b_src_files := empty.cpp +libtest_with_dependency_loop_b_shared_libraries := libtest_with_dependency_loop_c + +module := libtest_with_dependency_loop_b +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- +# libtest_with_dependency_loop_c.so +# ----------------------------------------------------------------------------- +libtest_with_dependency_loop_c_src_files := empty.cpp + +libtest_with_dependency_loop_c_shared_libraries := \ + libtest_with_dependency_loop_a + +module := libtest_with_dependency_loop_c +build_type := target +build_target := SHARED_LIBRARY +include $(TEST_PATH)/Android.build.mk + +# ----------------------------------------------------------------------------- # Library with dependency used by dlfcn tests # ----------------------------------------------------------------------------- libtest_with_dependency_src_files := \ diff --git a/tests/libs/dlopen_testlib_answer.cpp b/tests/libs/dlopen_testlib_answer.cpp new file mode 100644 index 0000000..a4d7504 --- /dev/null +++ b/tests/libs/dlopen_testlib_answer.cpp @@ -0,0 +1,25 @@ +/* + * 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. + */ + +extern "C" int dlopen_test_get_answer() { + return __ANSWER; +} + +#ifdef __ANSWER2 +extern "C" int dlopen_test_get_answer2() { + return __ANSWER2; +} +#endif |