am 4a4dc7b3: am b3ebfecd: Merge "Fix order of soinfo links (repairs libcxx tests)."
* commit '4a4dc7b37c3a26a349d771755fb8bfb0ba4a05c9': Fix order of soinfo links (repairs libcxx tests).
This commit is contained in:
commit
fa0f9cc9f1
@ -1778,8 +1778,8 @@ void soinfo::CallDestructors() {
|
|||||||
|
|
||||||
void soinfo::add_child(soinfo* child) {
|
void soinfo::add_child(soinfo* child) {
|
||||||
if (has_min_version(0)) {
|
if (has_min_version(0)) {
|
||||||
this->children.push_front(child);
|
child->parents.push_back(this);
|
||||||
child->parents.push_front(this);
|
this->children.push_back(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,7 @@ bionic-unit-tests_ldflags := \
|
|||||||
-Wl,-u,DlSymTestFunction \
|
-Wl,-u,DlSymTestFunction \
|
||||||
|
|
||||||
bionic-unit-tests_c_includes := \
|
bionic-unit-tests_c_includes := \
|
||||||
|
bionic/libc \
|
||||||
$(call include-path-for, libpagemap) \
|
$(call include-path-for, libpagemap) \
|
||||||
|
|
||||||
bionic-unit-tests_shared_libraries_target := \
|
bionic-unit-tests_shared_libraries_target := \
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "private/ScopeGuard.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define ASSERT_SUBSTR(needle, haystack) \
|
#define ASSERT_SUBSTR(needle, haystack) \
|
||||||
@ -130,6 +132,32 @@ TEST(dlfcn, ifunc_ctor_call) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TEST(dlfcn, dlopen_check_relocation_dt_needed_order) {
|
||||||
|
// This is the structure of the test library and
|
||||||
|
// its dt_needed libraries
|
||||||
|
// libtest_relo_check_dt_needed_order.so
|
||||||
|
// |
|
||||||
|
// +-> libtest_relo_check_dt_needed_order_1.so
|
||||||
|
// |
|
||||||
|
// +-> libtest_relo_check_dt_needed_order_2.so
|
||||||
|
//
|
||||||
|
// The root library references relo_test_get_answer_lib - which is defined
|
||||||
|
// in both dt_needed libraries, the correct relocation should
|
||||||
|
// use the function defined in libtest_relo_check_dt_needed_order_1.so
|
||||||
|
void* handle = nullptr;
|
||||||
|
auto guard = create_scope_guard([&]() {
|
||||||
|
dlclose(handle);
|
||||||
|
});
|
||||||
|
|
||||||
|
handle = dlopen("libtest_relo_check_dt_needed_order.so", RTLD_NOW);
|
||||||
|
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||||
|
|
||||||
|
typedef int (*fn_t) (void);
|
||||||
|
fn_t fn = reinterpret_cast<fn_t>(dlsym(handle, "relo_test_get_answer"));
|
||||||
|
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||||
|
ASSERT_EQ(1, fn());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(dlfcn, dlopen_check_order) {
|
TEST(dlfcn, dlopen_check_order) {
|
||||||
// Here is how the test library and its dt_needed
|
// Here is how the test library and its dt_needed
|
||||||
// libraries are arranged
|
// libraries are arranged
|
||||||
|
@ -256,6 +256,29 @@ build_type := target
|
|||||||
build_target := SHARED_LIBRARY
|
build_target := SHARED_LIBRARY
|
||||||
include $(TEST_PATH)/Android.build.mk
|
include $(TEST_PATH)/Android.build.mk
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# libtest_relo_check_dt_needed_order.so
|
||||||
|
# |
|
||||||
|
# +-> libtest_relo_check_dt_needed_order_1.so
|
||||||
|
# |
|
||||||
|
# +-> libtest_relo_check_dt_needed_order_2.so
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
libtest_relo_check_dt_needed_order_shared_libraries := \
|
||||||
|
libtest_relo_check_dt_needed_order_1 libtest_relo_check_dt_needed_order_2
|
||||||
|
|
||||||
|
libtest_relo_check_dt_needed_order_src_files := dlopen_testlib_relo_check_dt_needed_order.cpp
|
||||||
|
libtest_relo_check_dt_needed_order_1_src_files := dlopen_testlib_relo_check_dt_needed_order_1.cpp
|
||||||
|
libtest_relo_check_dt_needed_order_2_src_files := dlopen_testlib_relo_check_dt_needed_order_2.cpp
|
||||||
|
build_type := target
|
||||||
|
build_target := SHARED_LIBRARY
|
||||||
|
|
||||||
|
module := libtest_relo_check_dt_needed_order
|
||||||
|
include $(TEST_PATH)/Android.build.mk
|
||||||
|
module := libtest_relo_check_dt_needed_order_1
|
||||||
|
include $(TEST_PATH)/Android.build.mk
|
||||||
|
module := libtest_relo_check_dt_needed_order_2
|
||||||
|
include $(TEST_PATH)/Android.build.mk
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Library with dependency used by dlfcn tests
|
# Library with dependency used by dlfcn tests
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
21
tests/libs/dlopen_testlib_relo_check_dt_needed_order.cpp
Normal file
21
tests/libs/dlopen_testlib_relo_check_dt_needed_order.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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 relo_test_get_answer_lib();
|
||||||
|
|
||||||
|
extern "C" int relo_test_get_answer() {
|
||||||
|
return relo_test_get_answer_lib();
|
||||||
|
}
|
19
tests/libs/dlopen_testlib_relo_check_dt_needed_order_1.cpp
Normal file
19
tests/libs/dlopen_testlib_relo_check_dt_needed_order_1.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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 relo_test_get_answer_lib() {
|
||||||
|
return 1;
|
||||||
|
}
|
19
tests/libs/dlopen_testlib_relo_check_dt_needed_order_2.cpp
Normal file
19
tests/libs/dlopen_testlib_relo_check_dt_needed_order_2.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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 relo_test_get_answer_lib() {
|
||||||
|
return 2;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user