upload android base code part3
This commit is contained in:
parent
71b83c22f1
commit
b9e30e05b1
15122 changed files with 2089659 additions and 0 deletions
675
android/bionic/tests/libs/Android.bp
Normal file
675
android/bionic/tests/libs/Android.bp
Normal file
|
@ -0,0 +1,675 @@
|
|||
//
|
||||
// Copyright (C) 2012 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.
|
||||
//
|
||||
|
||||
cc_defaults {
|
||||
name: "bionic_testlib_defaults",
|
||||
host_supported: true,
|
||||
ldflags: [
|
||||
"-Wl,--rpath,${ORIGIN}",
|
||||
"-Wl,--enable-new-dtags",
|
||||
],
|
||||
relative_install_path: "bionic-loader-test-libs",
|
||||
gtest: false,
|
||||
sanitize: {
|
||||
address: false,
|
||||
coverage: false,
|
||||
},
|
||||
stl: "libc++_static",
|
||||
target: {
|
||||
darwin: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library to test gnu-styled hash
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libgnu-hash-table-library",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlext_test_library.cpp"],
|
||||
ldflags: ["-Wl,--hash-style=gnu"],
|
||||
arch: {
|
||||
mips: {
|
||||
enabled: false,
|
||||
},
|
||||
mips64: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library to test sysv-styled hash
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libsysv-hash-table-library",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlext_test_library.cpp"],
|
||||
ldflags: ["-Wl,--hash-style=sysv"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlext tests - with GNU RELRO program header
|
||||
// -----------------------------------------------------------------------------
|
||||
// In Android.mk to support creating symlinks
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlext tests - without GNU RELRO program header
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libdlext_test_norelro",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlext_test_library.cpp"],
|
||||
ldflags: ["-Wl,-z,norelro"],
|
||||
shared_libs = ["libtest_simple"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlext tests - different name non-default location
|
||||
// -----------------------------------------------------------------------------
|
||||
// In Android.mk to support installing to /data
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Libraries used by dlext tests for open from a zip-file
|
||||
// -----------------------------------------------------------------------------
|
||||
// In Android.mk to support installing to /data
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Library with soname which does not match filename
|
||||
// ----------------------------------------------------------------------------
|
||||
// In Android.mk to support zipped and aligned tests
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlext tests - zipped and aligned
|
||||
// -----------------------------------------------------------------------------
|
||||
// In Android.mk to support zipped and aligned tests
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlfcn tests
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_simple",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_simple.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlfcn nodelete tests
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_nodelete_1",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_nodelete_1.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlfcn nodelete tests
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_nodelete_2",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_nodelete_2.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by dlfcn nodelete tests
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_nodelete_dt_flags_1",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_nodelete_dt_flags_1.cpp"],
|
||||
ldflags: ["-Wl,-z,nodelete"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build test helper libraries for linker namespaces
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.linker_namespaces.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build DT_RUNPATH test helper libraries
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.dt_runpath.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build library with two parents
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build libtest_check_order_dlsym.so with its dependencies.
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build libtest_check_order_siblings.so with its dependencies.
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build libtest_check_order_root.so with its dependencies.
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build libtest_versioned_lib.so with its dependencies.
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.versioned_lib.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Build libraries needed by pthread_atfork tests
|
||||
// -----------------------------------------------------------------------------
|
||||
// include $(LOCAL_PATH)/Android.build.pthread_atfork.mk
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with dependency loop used by dlfcn tests
|
||||
//
|
||||
// libtest_with_dependency_loop -> a -> b -> c -> a
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_with_dependency_loop",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_loopy_root.cpp"],
|
||||
shared_libs: ["libtest_with_dependency_loop_a"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// libtest_with_dependency_loop_a.so
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_with_dependency_loop_a",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_loopy_a.cpp"],
|
||||
shared_libs: ["libtest_with_dependency_loop_b_tmp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// libtest_with_dependency_loop_b.so
|
||||
//
|
||||
// this is temporary placeholder - will be removed
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_with_dependency_loop_b_tmp",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_loopy_invalid.cpp"],
|
||||
ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// libtest_with_dependency_loop_b.so
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_with_dependency_loop_b",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_loopy_b.cpp"],
|
||||
shared_libs: ["libtest_with_dependency_loop_c"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// libtest_with_dependency_loop_c.so
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_with_dependency_loop_c",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_loopy_c.cpp"],
|
||||
shared_libs: ["libtest_with_dependency_loop_a"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// libtest_relo_check_dt_needed_order.so
|
||||
// |
|
||||
// +-> libtest_relo_check_dt_needed_order_1.so
|
||||
// |
|
||||
// +-> libtest_relo_check_dt_needed_order_2.so
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_relo_check_dt_needed_order",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"],
|
||||
shared_libs: [
|
||||
"libtest_relo_check_dt_needed_order_1",
|
||||
"libtest_relo_check_dt_needed_order_2",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_relo_check_dt_needed_order_1",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_relo_check_dt_needed_order_2",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with dependency used by dlfcn tests
|
||||
// -----------------------------------------------------------------------------
|
||||
// In Android.mk to support dependency on libdlext_test
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by ifunc tests
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_ifunc",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_ifunc.cpp"],
|
||||
|
||||
arch: {
|
||||
mips: {
|
||||
enabled: false,
|
||||
},
|
||||
mips64: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_ifunc_variable",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_ifunc_variable.cpp"],
|
||||
shared_libs: [ "libtest_ifunc_variable_impl" ],
|
||||
|
||||
arch: {
|
||||
mips: {
|
||||
enabled: false,
|
||||
},
|
||||
mips64: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_ifunc_variable_impl",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_ifunc_variable_impl.cpp"],
|
||||
|
||||
arch: {
|
||||
mips: {
|
||||
enabled: false,
|
||||
},
|
||||
mips64: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library used by atexit tests
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_atexit",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["atexit_testlib.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// This library is used by dl_load test to check symbol preempting
|
||||
// by main executable
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libdl_preempt_test_1",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dl_preempt_library_1.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// This library is used by dl_load test to check symbol preempting
|
||||
// by libdl_preempt_test_1.so
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libdl_preempt_test_2",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dl_preempt_library_2.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with DF_1_GLOBAL
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libdl_test_df_1_global",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dl_df_1_global.cpp"],
|
||||
ldflags: ["-Wl,-z,global"],
|
||||
|
||||
target: {
|
||||
host: {
|
||||
// TODO (dimitry): host ld.gold does not yet support -z global
|
||||
// remove this line once it is updated.
|
||||
ldflags: ["-fuse-ld=bfd"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library using symbol from libdl_test_df_1_global
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlsym_df_1_global",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dl_df_1_use_global.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with weak function
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlsym_weak_func",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlsym_weak_function.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library to check RTLD_LOCAL with dlsym in 'this'
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlsym_from_this",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlsym_from_this_symbol.cpp"],
|
||||
shared_libs: ["libtest_dlsym_from_this_child"],
|
||||
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlsym_from_this_child",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlsym_from_this_functions.cpp"],
|
||||
shared_libs: ["libtest_dlsym_from_this_grandchild"],
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlsym_from_this_grandchild",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlsym_from_this_symbol2.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Empty library
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_empty",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["empty.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with weak undefined function
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlopen_weak_undefined_func",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_weak_undefined.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Check that RTLD_NEXT of a libc symbol works in dlopened library
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_check_rtld_next_from_library",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["check_rtld_next_from_library.cpp"],
|
||||
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library with constructor that calls dlopen() b/7941716
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlopen_from_ctor",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"],
|
||||
target: {
|
||||
android: {
|
||||
shared_libs: ["libdl"],
|
||||
},
|
||||
host: {
|
||||
host_ldlibs: ["-ldl"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Libraries used to check init/fini call order
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_init_fini_order_root",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_check_init_fini_root.cpp"],
|
||||
shared_libs: [
|
||||
"libtest_init_fini_order_child",
|
||||
"libtest_init_fini_order_grand_child",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_init_fini_order_root2",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_check_init_fini_root.cpp"],
|
||||
shared_libs: [
|
||||
"libtest_init_fini_order_grand_child",
|
||||
"libtest_init_fini_order_child",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_init_fini_order_child",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_check_init_fini_child.cpp"],
|
||||
shared_libs: ["libtest_init_fini_order_grand_child"],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libtest_init_fini_order_grand_child",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["dlopen_check_init_fini_grand_child.cpp"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Library that depends on the library with constructor that calls dlopen() b/7941716
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_test_library {
|
||||
name: "libtest_dlopen_from_ctor_main",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["empty.cpp"],
|
||||
shared_libs: ["libtest_dlopen_from_ctor"],
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Tool to use to align the shared libraries in a zip file.
|
||||
// -----------------------------------------------------------------------------
|
||||
cc_binary_host {
|
||||
name: "bionic_tests_zipalign",
|
||||
srcs: ["bionic_tests_zipalign.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"libziparchive",
|
||||
"liblog",
|
||||
"libbase",
|
||||
"libz",
|
||||
"libutils",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libcfi-test",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["cfi_test_lib.cpp"],
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "libcfi-test-bad",
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["cfi_test_bad_lib.cpp"],
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "cfi_test_helper",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["cfi_test_helper.cpp"],
|
||||
ldflags: ["-rdynamic"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "cfi_test_helper2",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["cfi_test_helper2.cpp"],
|
||||
shared_libs: ["libcfi-test"],
|
||||
ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "preinit_getauxval_test_helper",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["preinit_getauxval_test_helper.cpp"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "preinit_syscall_test_helper",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["preinit_syscall_test_helper.cpp"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "ld_preload_test_helper",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_preload_test_helper.cpp"],
|
||||
shared_libs: ["ld_preload_test_helper_lib1"],
|
||||
ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "ld_preload_test_helper_lib1",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_preload_test_helper_lib1.cpp"],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "ld_preload_test_helper_lib2",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_preload_test_helper_lib2.cpp"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "ld_config_test_helper",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_config_test_helper.cpp"],
|
||||
shared_libs: ["ld_config_test_helper_lib1"],
|
||||
ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "ld_config_test_helper_lib1",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_config_test_helper_lib1.cpp"],
|
||||
shared_libs: ["ld_config_test_helper_lib2"],
|
||||
relative_install_path: "/ns2",
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "ld_config_test_helper_lib2",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_config_test_helper_lib2.cpp"],
|
||||
relative_install_path: "/ns2",
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
name: "ld_config_test_helper_lib3",
|
||||
host_supported: false,
|
||||
defaults: ["bionic_testlib_defaults"],
|
||||
srcs: ["ld_config_test_helper_lib3.cpp"],
|
||||
}
|
76
android/bionic/tests/libs/Android.build.dlext_testzip.mk
Normal file
76
android/bionic/tests/libs/Android.build.dlext_testzip.mk
Normal file
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Library used by dlext tests - zipped and aligned
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
BIONIC_TESTS_ZIPALIGN := $(HOST_OUT_EXECUTABLES)/bionic_tests_zipalign
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_CLASS := NATIVE_TESTS
|
||||
LOCAL_MODULE := libdlext_test_zip_zipaligned
|
||||
LOCAL_MODULE_SUFFIX := .zip
|
||||
LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_zip
|
||||
LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
|
||||
|
||||
include $(BUILD_SYSTEM)/base_rules.mk
|
||||
|
||||
my_shared_libs := \
|
||||
$(call intermediates-dir-for,SHARED_LIBRARIES,libdlext_test_zip,,,$(bionic_2nd_arch_prefix))/libdlext_test_zip.so \
|
||||
$(call intermediates-dir-for,SHARED_LIBRARIES,libatest_simple_zip,,,$(bionic_2nd_arch_prefix))/libatest_simple_zip.so
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBS := $(my_shared_libs)
|
||||
$(LOCAL_BUILT_MODULE): $(my_shared_libs) $(BIONIC_TESTS_ZIPALIGN)
|
||||
@echo "Aligning zip: $@"
|
||||
$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)/libdir
|
||||
$(hide) cp $(PRIVATE_SHARED_LIBS) $(dir $@)/libdir
|
||||
$(hide) (cd $(dir $@) && touch empty_file.txt && zip -qrD0 $(notdir $@).unaligned empty_file.txt libdir/*.so)
|
||||
$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_CLASS := NATIVE_TESTS
|
||||
LOCAL_MODULE := libdlext_test_runpath_zip_zipaligned
|
||||
LOCAL_MODULE_SUFFIX := .zip
|
||||
LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_runpath_zip
|
||||
LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
|
||||
|
||||
include $(BUILD_SYSTEM)/base_rules.mk
|
||||
lib_d := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_d_zip,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_d_zip.so
|
||||
lib_a := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_a,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_a.so
|
||||
lib_b := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_b,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_b.so
|
||||
lib_c := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_c,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_c.so
|
||||
lib_x := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_x,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_x.so
|
||||
|
||||
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_D := $(lib_d)
|
||||
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_A := $(lib_a)
|
||||
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_B := $(lib_b)
|
||||
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_C := $(lib_c)
|
||||
$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_X := $(lib_x)
|
||||
$(LOCAL_BUILT_MODULE) : $(lib_d) $(lib_a) $(lib_b) $(lib_c) $(lib_x) $(BIONIC_TESTS_ZIPALIGN)
|
||||
@echo "Aligning zip: $@"
|
||||
$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)/libdir && \
|
||||
mkdir -p $(dir $@)/libdir/dt_runpath_a && mkdir -p $(dir $@)/libdir/dt_runpath_b_c_x
|
||||
$(hide) cp $(PRIVATE_LIB_D) $(dir $@)/libdir
|
||||
$(hide) cp $(PRIVATE_LIB_A) $(dir $@)/libdir/dt_runpath_a
|
||||
$(hide) cp $(PRIVATE_LIB_B) $(dir $@)/libdir/dt_runpath_b_c_x
|
||||
$(hide) cp $(PRIVATE_LIB_C) $(dir $@)/libdir/dt_runpath_b_c_x
|
||||
$(hide) cp $(PRIVATE_LIB_X) $(dir $@)/libdir/dt_runpath_b_c_x
|
||||
$(hide) (cd $(dir $@) && touch empty_file.txt && zip -qrD0 $(notdir $@).unaligned empty_file.txt libdir)
|
||||
$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dlfcn tests to verify local group ref_counting
|
||||
# libtest_two_parents*.so
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._child.so - correct answer
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_two_parents_child_src_files := \
|
||||
dlopen_2_parents_reloc_answer.cpp
|
||||
|
||||
module := libtest_two_parents_child
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._parent1.so - correct answer
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_two_parents_parent1_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_two_parents_parent1_shared_libraries := libtest_two_parents_child
|
||||
libtest_two_parents_parent1_cflags := -D__ANSWER=42
|
||||
module := libtest_two_parents_parent1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._parent2.so - incorrect answer
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_two_parents_parent2_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_two_parents_parent2_shared_libraries := libtest_two_parents_child
|
||||
libtest_two_parents_parent2_cflags := -D__ANSWER=1
|
||||
module := libtest_two_parents_parent2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dlfcn tests to verify correct load order:
|
||||
# libtest_check_order_2_right.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_2_right_src_files := \
|
||||
dlopen_check_order_dlsym_answer.cpp
|
||||
|
||||
libtest_check_order_dlsym_2_right_cflags := -D__ANSWER=42
|
||||
module := libtest_check_order_dlsym_2_right
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_a.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_a_src_files := \
|
||||
dlopen_check_order_dlsym_answer.cpp
|
||||
|
||||
libtest_check_order_dlsym_a_cflags := -D__ANSWER=1
|
||||
module := libtest_check_order_dlsym_a
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_b.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_b_src_files := \
|
||||
dlopen_check_order_dlsym_answer.cpp
|
||||
|
||||
libtest_check_order_dlsym_b_cflags := -D__ANSWER=2 -D__ANSWER2=43
|
||||
module := libtest_check_order_dlsym_b
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_c.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_3_c_src_files := \
|
||||
dlopen_check_order_dlsym_answer.cpp
|
||||
|
||||
libtest_check_order_dlsym_3_c_cflags := -D__ANSWER=3
|
||||
module := libtest_check_order_dlsym_3_c
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_d.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_d_src_files := \
|
||||
dlopen_check_order_dlsym_answer.cpp
|
||||
|
||||
libtest_check_order_dlsym_d_shared_libraries := libtest_check_order_dlsym_b
|
||||
libtest_check_order_dlsym_d_cflags := -D__ANSWER=4 -D__ANSWER2=4
|
||||
module := libtest_check_order_dlsym_d
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_left.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_1_left_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_check_order_dlsym_1_left_shared_libraries := libtest_check_order_dlsym_a libtest_check_order_dlsym_b
|
||||
|
||||
module := libtest_check_order_dlsym_1_left
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_dlsym_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_check_order_dlsym_shared_libraries := libtest_check_order_dlsym_1_left \
|
||||
libtest_check_order_dlsym_2_right libtest_check_order_dlsym_3_c
|
||||
|
||||
module := libtest_check_order_dlsym
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
|
@ -0,0 +1,56 @@
|
|||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dlfcn tests to verify correct relocation order:
|
||||
# libtest_check_order_reloc_root*.so
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._1.so - empty
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_root_1_src_files := \
|
||||
empty.cpp
|
||||
|
||||
|
||||
module := libtest_check_order_reloc_root_1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._2.so - this one has the incorrect answer
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_root_2_src_files := \
|
||||
dlopen_check_order_reloc_root_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_root_2_cflags := -D__ANSWER=2
|
||||
|
||||
module := libtest_check_order_reloc_root_2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_reloc_root.so <- implements get_answer3()
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_root_src_files := \
|
||||
dlopen_check_order_reloc_root_answer.cpp
|
||||
|
||||
libtest_check_order_reloc_root_shared_libraries := \
|
||||
libtest_check_order_reloc_root_1 \
|
||||
libtest_check_order_reloc_root_2
|
||||
|
||||
module := libtest_check_order_reloc_root
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
|
@ -0,0 +1,158 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dlfcn tests to verify correct relocation order:
|
||||
# libtest_check_order_reloc_siblings*.so
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._1.so - empty
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_1_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_1_shared_libraries := \
|
||||
libtest_check_order_reloc_siblings_a \
|
||||
libtest_check_order_reloc_siblings_b
|
||||
|
||||
module := libtest_check_order_reloc_siblings_1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._2.so - empty
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_2_src_files := \
|
||||
dlopen_check_order_reloc_grandchild_answer.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_2_shared_libraries := \
|
||||
libtest_check_order_reloc_siblings_c \
|
||||
libtest_check_order_reloc_siblings_d
|
||||
|
||||
libtest_check_order_reloc_siblings_2_allow_undefined_symbols := true
|
||||
module := libtest_check_order_reloc_siblings_2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._3.so - get_answer2();
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_3_src_files := \
|
||||
dlopen_check_order_reloc_nephew_answer.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_3_shared_libraries := \
|
||||
libtest_check_order_reloc_siblings_e \
|
||||
libtest_check_order_reloc_siblings_f
|
||||
|
||||
module := libtest_check_order_reloc_siblings_3
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._a.so <- correct impl
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_a_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_a_cflags := -D__ANSWER=42
|
||||
module := libtest_check_order_reloc_siblings_a
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._b.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_b_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_b_cflags := -D__ANSWER=1
|
||||
module := libtest_check_order_reloc_siblings_b
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._c.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_c_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_c_cflags := -D__ANSWER=2
|
||||
libtest_check_order_reloc_siblings_c_shared_libraries := \
|
||||
libtest_check_order_reloc_siblings_c_1 \
|
||||
libtest_check_order_reloc_siblings_c_2
|
||||
|
||||
module := libtest_check_order_reloc_siblings_c
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._d.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_d_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_d_cflags := -D__ANSWER=3
|
||||
module := libtest_check_order_reloc_siblings_d
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._e.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_e_src_files := \
|
||||
dlopen_check_order_reloc_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_e_cflags := -D__ANSWER=4
|
||||
module := libtest_check_order_reloc_siblings_e
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._f.so <- get_answer()
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_f_src_files := \
|
||||
dlopen_check_order_reloc_answer.cpp
|
||||
|
||||
module := libtest_check_order_reloc_siblings_f
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._c_1.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_c_1_src_files := \
|
||||
dlopen_check_order_reloc_grandchild_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_c_1_cflags := -D__ANSWER=42
|
||||
module := libtest_check_order_reloc_siblings_c_1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# ..._c_2.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_c_2_src_files := \
|
||||
dlopen_check_order_reloc_grandchild_answer_impl.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_c_2_cflags := -D__ANSWER=0
|
||||
module := libtest_check_order_reloc_siblings_c_2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# libtest_check_order_reloc_siblings.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_check_order_reloc_siblings_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_check_order_reloc_siblings_shared_libraries := \
|
||||
libtest_check_order_reloc_siblings_1 \
|
||||
libtest_check_order_reloc_siblings_2 \
|
||||
libtest_check_order_reloc_siblings_3
|
||||
|
||||
module := libtest_check_order_reloc_siblings
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
98
android/bionic/tests/libs/Android.build.dt_runpath.mk
Normal file
98
android/bionic/tests/libs/Android.build.dt_runpath.mk
Normal file
|
@ -0,0 +1,98 @@
|
|||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dt_runpath tests.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
# libtest_dt_runpath_d.so runpath: ${ORIGIN}/dt_runpath_b_c_x
|
||||
# |-> dt_runpath_b_c_x/libtest_dt_runpath_b.so runpath: ${ORIGIN}/../dt_runpath_a
|
||||
# | |-> dt_runpath_a/libtest_dt_runpath_a.so
|
||||
# |-> dt_runpath_b_c_x/libtest_dt_runpath_c.so runpath: ${ORIGIN}/invalid_dt_runpath
|
||||
# | |-> libtest_dt_runpath_a.so (soname)
|
||||
#
|
||||
# This one is used to test dlopen
|
||||
# dt_runpath_b_c_x/libtest_dt_runpath_x.so
|
||||
#
|
||||
|
||||
# A leaf library in a non-standard directory.
|
||||
libtest_dt_runpath_a_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_dt_runpath_a_relative_path := dt_runpath_a
|
||||
module := libtest_dt_runpath_a
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# Depends on library A with a DT_RUNPATH
|
||||
libtest_dt_runpath_b_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_dt_runpath_b_shared_libraries := libtest_dt_runpath_a
|
||||
libtest_dt_runpath_b_ldflags := -Wl,--rpath,\$${ORIGIN}/../dt_runpath_a -Wl,--enable-new-dtags
|
||||
libtest_dt_runpath_b_relative_path := dt_runpath_b_c_x
|
||||
module := libtest_dt_runpath_b
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# Depends on library A with an incorrect DT_RUNPATH. This does not matter
|
||||
# because B is the first in the D (below) dependency order, and library A
|
||||
# is already loaded using the correct DT_RUNPATH from library B.
|
||||
libtest_dt_runpath_c_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_dt_runpath_c_shared_libraries := libtest_dt_runpath_a
|
||||
libtest_dt_runpath_c_ldflags := -Wl,--rpath,\$${ORIGIN}/invalid_dt_runpath -Wl,--enable-new-dtags
|
||||
libtest_dt_runpath_c_relative_path := dt_runpath_b_c_x
|
||||
module := libtest_dt_runpath_c
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# D depends on B and C with DT_RUNPATH.
|
||||
libtest_dt_runpath_d_src_files := \
|
||||
dlopen_b.cpp
|
||||
|
||||
libtest_dt_runpath_d_shared_libraries := libtest_dt_runpath_b libtest_dt_runpath_c
|
||||
libtest_dt_runpath_d_ldflags := -Wl,--rpath,\$${ORIGIN}/dt_runpath_b_c_x -Wl,--enable-new-dtags
|
||||
libtest_dt_runpath_d_ldlibs := -ldl
|
||||
module := libtest_dt_runpath_d
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# D version for open-from-zip test with runpath
|
||||
module := libtest_dt_runpath_d_zip
|
||||
|
||||
libtest_dt_runpath_d_zip_src_files := \
|
||||
dlopen_b.cpp
|
||||
|
||||
libtest_dt_runpath_d_zip_shared_libraries := libtest_dt_runpath_b libtest_dt_runpath_c
|
||||
libtest_dt_runpath_d_zip_ldflags := -Wl,--rpath,\$${ORIGIN}/dt_runpath_b_c_x -Wl,--enable-new-dtags
|
||||
libtest_dt_runpath_d_zip_ldlibs := -ldl
|
||||
libtest_dt_runpath_d_zip_install_to_native_tests_dir := $(module)
|
||||
|
||||
module_tag := optional
|
||||
build_type := target
|
||||
build_target := SHARED_LIBRARY
|
||||
include $(TEST_PATH)/Android.build.mk
|
||||
|
||||
|
||||
# A leaf library in a directory library D has DT_RUNPATH for.
|
||||
libtest_dt_runpath_x_src_files := \
|
||||
empty.cpp
|
||||
|
||||
libtest_dt_runpath_x_relative_path := dt_runpath_b_c_x
|
||||
module := libtest_dt_runpath_x
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
93
android/bionic/tests/libs/Android.build.linker_namespaces.mk
Normal file
93
android/bionic/tests/libs/Android.build.linker_namespaces.mk
Normal file
|
@ -0,0 +1,93 @@
|
|||
#
|
||||
# Copyright (C) 2015 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# This set of libraries are used to verify linker namespaces.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Test cases
|
||||
# 1. Check that private libraries loaded in different namespaces are
|
||||
# different. Check that dlsym does not confuse them.
|
||||
# 2. Check that public libraries loaded in different namespaces are shared
|
||||
# between them.
|
||||
# 3. Check that namespace sticks on dlopen
|
||||
# 4. Check that having access to shared library (libnstest_public.so)
|
||||
# does not expose symbols from dependent library (libnstest_public_internal.so)
|
||||
#
|
||||
# Dependency tree (visibility)
|
||||
# libnstest_root.so (this should be local to the namespace)
|
||||
# +-> libnstest_public.so
|
||||
# +-> libnstest_public_internal.so
|
||||
# +-> libnstest_private.so
|
||||
#
|
||||
# libnstest_dlopened.so (library in private namespace dlopened from libnstest_root.so)
|
||||
# -----------------------------------------------------------------------------
|
||||
libnstest_root_src_files := namespaces_root.cpp
|
||||
libnstest_root_shared_libraries := libnstest_public libnstest_private
|
||||
libnstest_root_relative_install_path := private_namespace_libs
|
||||
module := libnstest_root
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
libnstest_public_internal_src_files := namespaces_public_internal.cpp
|
||||
module := libnstest_public_internal
|
||||
libnstest_public_internal_relative_install_path := public_namespace_libs
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
libnstest_public_src_files := namespaces_public.cpp
|
||||
libnstest_public_shared_libraries := libnstest_public_internal
|
||||
module := libnstest_public
|
||||
libnstest_public_relative_install_path := public_namespace_libs
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
libnstest_private_src_files := namespaces_private.cpp
|
||||
libnstest_private_relative_install_path := private_namespace_libs
|
||||
module := libnstest_private
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
libnstest_dlopened_src_files := namespaces_dlopened.cpp
|
||||
libnstest_dlopened_relative_install_path := private_namespace_libs
|
||||
module := libnstest_dlopened
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# This set of libraries is to test isolated namespaces
|
||||
#
|
||||
# Isolated namespaces do not allow loading of the library outside of
|
||||
# the search paths.
|
||||
#
|
||||
# This library cannot be loaded in isolated namespace because one of DT_NEEDED
|
||||
# libraries is outside of the search paths.
|
||||
#
|
||||
# libnstest_root_not_isolated.so (DT_RUNPATH = $ORIGIN/../private_namespace_libs_external/)
|
||||
# +-> libnstest_public.so
|
||||
# +-> libnstest_private_external.so (located in $ORIGIN/../private_namespace_libs_external/)
|
||||
#
|
||||
# Search path: $NATIVE_TESTS/private_namespace_libs/
|
||||
# -----------------------------------------------------------------------------
|
||||
libnstest_root_not_isolated_src_files := namespaces_root.cpp
|
||||
libnstest_root_not_isolated_shared_libraries := libnstest_public libnstest_private_external
|
||||
libnstest_root_not_isolated_relative_install_path := private_namespace_libs
|
||||
libnstest_root_not_isolated_ldflags := -Wl,--rpath,\$$ORIGIN/../private_namespace_libs_external \
|
||||
-Wl,--enable-new-dtags
|
||||
|
||||
module := libnstest_root_not_isolated
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
libnstest_private_external_src_files := namespaces_private.cpp
|
||||
libnstest_private_external_relative_install_path := private_namespace_libs_external
|
||||
module := libnstest_private_external
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
25
android/bionic/tests/libs/Android.build.pthread_atfork.mk
Normal file
25
android/bionic/tests/libs/Android.build.pthread_atfork.mk
Normal file
|
@ -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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# This library used to test phtread_atfork handler behaviour
|
||||
# during/after dlclose.
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_pthread_atfork_src_files := pthread_atfork.cpp
|
||||
|
||||
module := libtest_pthread_atfork
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
19
android/bionic/tests/libs/Android.build.testlib.host.mk
Normal file
19
android/bionic/tests/libs/Android.build.testlib.host.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Copyright (C) 2016 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.
|
||||
#
|
||||
|
||||
build_target := SHARED_LIBRARY
|
||||
build_type := host
|
||||
include $(LOCAL_PATH)/Android.build.testlib.internal.mk
|
27
android/bionic/tests/libs/Android.build.testlib.internal.mk
Normal file
27
android/bionic/tests/libs/Android.build.testlib.internal.mk
Normal file
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# Copyright (C) 2016 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.
|
||||
#
|
||||
|
||||
# 1. Install test libraries to $ANDROID_DATA/nativetests../bionic-loader-test-libs/
|
||||
# by default.
|
||||
ifeq ($($(module)_relative_install_path),)
|
||||
$(module)_install_to_native_tests_dir := bionic-loader-test-libs
|
||||
else
|
||||
$(module)_install_to_native_tests_dir := bionic-loader-test-libs/$($(module)_relative_install_path)
|
||||
endif
|
||||
# 2. Set dt_runpath to origin to resolve dependencies
|
||||
$(module)_ldflags += -Wl,--rpath,\$${ORIGIN} -Wl,--enable-new-dtags
|
||||
|
||||
include $(TEST_PATH)/Android.build.mk
|
19
android/bionic/tests/libs/Android.build.testlib.mk
Normal file
19
android/bionic/tests/libs/Android.build.testlib.mk
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.
|
||||
#
|
||||
|
||||
include $(LOCAL_PATH)/Android.build.testlib.host.mk
|
||||
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
19
android/bionic/tests/libs/Android.build.testlib.target.mk
Normal file
19
android/bionic/tests/libs/Android.build.testlib.target.mk
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.
|
||||
#
|
||||
|
||||
build_target := SHARED_LIBRARY
|
||||
build_type := target
|
||||
include $(LOCAL_PATH)/Android.build.testlib.internal.mk
|
120
android/bionic/tests/libs/Android.build.versioned_lib.mk
Normal file
120
android/bionic/tests/libs/Android.build.versioned_lib.mk
Normal file
|
@ -0,0 +1,120 @@
|
|||
#
|
||||
# Copyright (C) 2015 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.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used to test versioned symbols
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_uselibv1_src_files := versioned_uselib.cpp
|
||||
|
||||
libtest_versioned_uselibv1_shared_libraries := \
|
||||
libtest_versioned_libv1
|
||||
|
||||
module := libtest_versioned_uselibv1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_uselibv2_src_files := \
|
||||
versioned_uselib.cpp
|
||||
|
||||
libtest_versioned_uselibv2_shared_libraries := \
|
||||
libtest_versioned_libv2
|
||||
|
||||
libtest_versioned_uselibv2_ldflags := \
|
||||
-Wl,--version-script,$(LOCAL_PATH)/versioned_uselib.map
|
||||
|
||||
module := libtest_versioned_uselibv2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_uselibv2_other_src_files := \
|
||||
versioned_uselib.cpp
|
||||
|
||||
libtest_versioned_uselibv2_other_shared_libraries := \
|
||||
libtest_versioned_otherlib_empty libtest_versioned_libv2
|
||||
|
||||
module := libtest_versioned_uselibv2_other
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_uselibv3_other_src_files := \
|
||||
versioned_uselib.cpp
|
||||
|
||||
libtest_versioned_uselibv3_other_shared_libraries := \
|
||||
libtest_versioned_otherlib_empty libtest_versioned_lib
|
||||
|
||||
module := libtest_versioned_uselibv3_other
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# lib v1 - this one used during static linking but never used at runtime
|
||||
# which forces libtest_versioned_uselibv1 to use function v1 from
|
||||
# libtest_versioned_lib.so
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_libv1_src_files := \
|
||||
versioned_lib_v1.cpp
|
||||
|
||||
libtest_versioned_libv1_ldflags := \
|
||||
-Wl,--version-script,$(LOCAL_PATH)/versioned_lib_v1.map \
|
||||
-Wl,-soname,libtest_versioned_lib.so
|
||||
|
||||
module := libtest_versioned_libv1
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# lib v2 - to make libtest_versioned_uselibv2.so use version 2 of versioned_function()
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_libv2_src_files := \
|
||||
versioned_lib_v2.cpp
|
||||
|
||||
libtest_versioned_libv2_ldflags := \
|
||||
-Wl,--version-script,$(LOCAL_PATH)/versioned_lib_v2.map \
|
||||
-Wl,-soname,libtest_versioned_lib.so
|
||||
|
||||
module := libtest_versioned_libv2
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# last version - this one is used at the runtime and exports 3 versions
|
||||
# of versioned_symbol().
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_lib_src_files := \
|
||||
versioned_lib_v3.cpp
|
||||
|
||||
libtest_versioned_lib_ldflags := \
|
||||
-Wl,--version-script,$(LOCAL_PATH)/versioned_lib_v3.map
|
||||
|
||||
module := libtest_versioned_lib
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# This library is empty, the actual implementation will provide an unversioned
|
||||
# symbol for versioned_function().
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_otherlib_empty_src_files := empty.cpp
|
||||
|
||||
libtest_versioned_otherlib_empty_ldflags := -Wl,-soname,libtest_versioned_otherlib.so
|
||||
module := libtest_versioned_otherlib_empty
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_versioned_otherlib_src_files := versioned_lib_other.cpp
|
||||
|
||||
libtest_versioned_otherlib_ldflags := \
|
||||
-Wl,--version-script,$(LOCAL_PATH)/versioned_lib_other.map
|
||||
|
||||
module := libtest_versioned_otherlib
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
163
android/bionic/tests/libs/Android.mk
Normal file
163
android/bionic/tests/libs/Android.mk
Normal file
|
@ -0,0 +1,163 @@
|
|||
#
|
||||
# Copyright (C) 2012 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
TEST_PATH := $(LOCAL_PATH)/..
|
||||
|
||||
common_cppflags :=
|
||||
common_additional_dependencies := \
|
||||
$(LOCAL_PATH)/Android.mk \
|
||||
$(LOCAL_PATH)/Android.build.dt_runpath.mk \
|
||||
$(LOCAL_PATH)/Android.build.dlext_testzip.mk \
|
||||
$(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk \
|
||||
$(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk \
|
||||
$(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk \
|
||||
$(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk \
|
||||
$(LOCAL_PATH)/Android.build.linker_namespaces.mk \
|
||||
$(LOCAL_PATH)/Android.build.pthread_atfork.mk \
|
||||
$(LOCAL_PATH)/Android.build.testlib.mk \
|
||||
$(LOCAL_PATH)/Android.build.testlib.target.mk \
|
||||
$(LOCAL_PATH)/Android.build.versioned_lib.mk \
|
||||
$(TEST_PATH)/Android.build.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Library used by dlext tests - with GNU RELRO program header
|
||||
# -----------------------------------------------------------------------------
|
||||
libdlext_test_src_files := \
|
||||
dlext_test_library.cpp \
|
||||
|
||||
libdlext_test_ldflags := \
|
||||
-Wl,-z,relro \
|
||||
|
||||
libdlext_test_shared_libraries := libtest_simple
|
||||
|
||||
module := libdlext_test
|
||||
module_tag := optional
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Library used by dlext tests - different name non-default location
|
||||
# -----------------------------------------------------------------------------
|
||||
module := libdlext_test_fd
|
||||
|
||||
libdlext_test_fd_src_files := \
|
||||
dlext_test_library.cpp \
|
||||
|
||||
libdlext_test_fd_shared_libraries := libtest_simple
|
||||
|
||||
libdlext_test_fd_relative_install_path := $(module)
|
||||
|
||||
libdlext_test_fd_ldflags := -Wl,--rpath,\$${ORIGIN}/.. -Wl,--enable-new-dtags
|
||||
|
||||
module_tag := optional
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Libraries used by dlext tests for open from a zip-file
|
||||
# -----------------------------------------------------------------------------
|
||||
module := libdlext_test_zip
|
||||
|
||||
libdlext_test_zip_src_files := \
|
||||
dlext_test_library.cpp \
|
||||
|
||||
libdlext_test_zip_shared_libraries := libatest_simple_zip
|
||||
|
||||
libdlext_test_zip_relative_install_path := $(module)
|
||||
module_tag := optional
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
module := libatest_simple_zip
|
||||
|
||||
libatest_simple_zip_src_files := \
|
||||
dlopen_testlib_simple.cpp
|
||||
|
||||
libatest_simple_zip_relative_install_path := $(module)
|
||||
module_tag := optional
|
||||
include $(LOCAL_PATH)/Android.build.testlib.target.mk
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Library with soname which does not match filename
|
||||
# ----------------------------------------------------------------------------
|
||||
libdlext_test_different_soname_src_files := \
|
||||
dlext_test_library.cpp \
|
||||
|
||||
module := libdlext_test_different_soname
|
||||
module_tag := optional
|
||||
libdlext_test_different_soname_ldflags := -Wl,-soname=libdlext_test_soname.so
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Library used by dlext tests - zipped and aligned
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(CLEAR_VARS)
|
||||
bionic_2nd_arch_prefix :=
|
||||
include $(LOCAL_PATH)/Android.build.dlext_testzip.mk
|
||||
ifneq ($(TARGET_2ND_ARCH),)
|
||||
bionic_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
|
||||
include $(LOCAL_PATH)/Android.build.dlext_testzip.mk
|
||||
endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build test helper libraries for linker namespaces
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.linker_namespaces.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build DT_RUNPATH test helper libraries
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.dt_runpath.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build library with two parents
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build libtest_check_order_dlsym.so with its dependencies.
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build libtest_check_order_siblings.so with its dependencies.
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build libtest_check_order_root.so with its dependencies.
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build libtest_versioned_lib.so with its dependencies.
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.versioned_lib.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build libraries needed by pthread_atfork tests
|
||||
# -----------------------------------------------------------------------------
|
||||
include $(LOCAL_PATH)/Android.build.pthread_atfork.mk
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Library with dependency used by dlfcn tests
|
||||
# -----------------------------------------------------------------------------
|
||||
libtest_with_dependency_src_files := \
|
||||
dlopen_testlib_simple.cpp
|
||||
|
||||
libtest_with_dependency_shared_libraries := libdlext_test
|
||||
|
||||
module := libtest_with_dependency
|
||||
include $(LOCAL_PATH)/Android.build.testlib.mk
|
102
android/bionic/tests/libs/atexit_testlib.cpp
Normal file
102
android/bionic/tests/libs/atexit_testlib.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
// use external control number from main test
|
||||
static std::string* atexit_sequence = nullptr;
|
||||
static bool* atexit_valid_this_in_static_dtor = nullptr;
|
||||
static bool* atexit_attr_dtor_called = nullptr;
|
||||
|
||||
static int cxx_ctor_called = 0;
|
||||
static int attr_ctor_called = 0;
|
||||
|
||||
static class AtExitStaticClass {
|
||||
public:
|
||||
AtExitStaticClass() {
|
||||
expected_this = this;
|
||||
cxx_ctor_called = 1;
|
||||
}
|
||||
~AtExitStaticClass() {
|
||||
if (atexit_valid_this_in_static_dtor) {
|
||||
*atexit_valid_this_in_static_dtor = (expected_this == this);
|
||||
}
|
||||
}
|
||||
private:
|
||||
static const AtExitStaticClass* expected_this;
|
||||
|
||||
} static_obj;
|
||||
|
||||
const AtExitStaticClass* AtExitStaticClass::expected_this = nullptr;
|
||||
|
||||
// 4
|
||||
static void atexit_handler_from_atexit_from_atexit2() {
|
||||
*atexit_sequence += " on";
|
||||
}
|
||||
|
||||
// 3
|
||||
static void atexit_handler_from_atexit_from_atexit1() {
|
||||
*atexit_sequence += " sat";
|
||||
}
|
||||
|
||||
// 2
|
||||
static void atexit_handler_from_atexit() {
|
||||
*atexit_sequence += " Dumpty";
|
||||
// register 2 others
|
||||
atexit(atexit_handler_from_atexit_from_atexit2);
|
||||
atexit(atexit_handler_from_atexit_from_atexit1);
|
||||
}
|
||||
|
||||
// 1
|
||||
static void atexit_handler_with_atexit() {
|
||||
*atexit_sequence += "Humpty";
|
||||
atexit(atexit_handler_from_atexit);
|
||||
}
|
||||
|
||||
// last
|
||||
static void atexit_handler_regular() {
|
||||
*atexit_sequence += " a wall";
|
||||
}
|
||||
|
||||
// attribute c-tor and d-tor
|
||||
static void __attribute__((constructor)) atexit_attr_ctor() {
|
||||
attr_ctor_called = 1;
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) atexit_attr_dtor() {
|
||||
if (atexit_attr_dtor_called) {
|
||||
*atexit_attr_dtor_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void register_atexit(std::string* sequence, bool* valid_this_in_static_dtor, bool* attr_dtor_called) {
|
||||
atexit_sequence = sequence;
|
||||
atexit_valid_this_in_static_dtor = valid_this_in_static_dtor;
|
||||
atexit_attr_dtor_called = attr_dtor_called;
|
||||
atexit(atexit_handler_regular);
|
||||
atexit(atexit_handler_with_atexit);
|
||||
}
|
||||
|
||||
extern "C" int get_cxx_ctor_called() {
|
||||
return cxx_ctor_called;
|
||||
}
|
||||
|
||||
extern "C" int get_attr_ctor_called() {
|
||||
return attr_ctor_called;
|
||||
}
|
||||
|
160
android/bionic/tests/libs/bionic_tests_zipalign.cpp
Normal file
160
android/bionic/tests/libs/bionic_tests_zipalign.cpp
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <ziparchive/zip_archive.h>
|
||||
#include <ziparchive/zip_archive_stream_entry.h>
|
||||
#include <ziparchive/zip_writer.h>
|
||||
|
||||
static void usage() {
|
||||
fprintf(stderr, "usage: bionic_tests_zipalign ALIGNMENT INPUT_ZIP_FILE OUTPUT_ZIP_FILE\n");
|
||||
fprintf(stderr, " ALIGNMENT:\n");
|
||||
fprintf(stderr, " The new alignment of all entries in the new zip file.\n");
|
||||
fprintf(stderr, " INPUT_ZIP_FILE:\n");
|
||||
fprintf(stderr, " The input zip file that will be read but left unmodified.\n");
|
||||
fprintf(stderr, " OUTPUT_ZIP_FILE:\n");
|
||||
fprintf(stderr, " The output zip file that will be created from the input file.\n");
|
||||
}
|
||||
|
||||
using ZipData = std::pair<std::unique_ptr<ZipEntry>, std::unique_ptr<ZipString>>;
|
||||
|
||||
static bool GetEntries(ZipArchiveHandle handle, std::vector<ZipData>* entries) {
|
||||
void* cookie;
|
||||
int32_t return_value = StartIteration(handle, &cookie, nullptr, nullptr);
|
||||
if (return_value != 0) {
|
||||
fprintf(stderr, "Unable to iterate over entries: %s\n", ErrorCodeString(return_value));
|
||||
return false;
|
||||
}
|
||||
|
||||
ZipEntry entry;
|
||||
ZipString name;
|
||||
while ((return_value = Next(cookie, &entry, &name)) == 0) {
|
||||
entries->emplace_back(std::make_pair(std::make_unique<ZipEntry>(entry),
|
||||
std::make_unique<ZipString>(name)));
|
||||
}
|
||||
if (return_value != -1) {
|
||||
fprintf(stderr, "Error while iterating over zip entries: %s\n", ErrorCodeString(return_value));
|
||||
} else {
|
||||
// Sort by offset.
|
||||
std::sort(entries->begin(), entries->end(),
|
||||
[](ZipData& a, ZipData& b) { return a.first->offset < b.first->offset; });
|
||||
}
|
||||
|
||||
EndIteration(cookie);
|
||||
return return_value == -1;
|
||||
}
|
||||
|
||||
static bool CreateAlignedZip(ZipArchiveHandle& handle, FILE* zip_dst, uint32_t alignment) {
|
||||
std::vector<ZipData> entries;
|
||||
// We will not free the memory created in entries since the program
|
||||
// terminates right after this function is called.
|
||||
if (!GetEntries(handle, &entries)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ZipWriter writer(zip_dst);
|
||||
|
||||
int32_t error;
|
||||
for (auto& entry : entries) {
|
||||
ZipEntry* zip_entry = entry.first.get();
|
||||
ZipString* zip_str = entry.second.get();
|
||||
|
||||
size_t flags = 0;
|
||||
if ((zip_entry->method & kCompressDeflated) != 0) {
|
||||
flags |= ZipWriter::kCompress;
|
||||
}
|
||||
std::string zip_name(reinterpret_cast<const char*>(zip_str->name), zip_str->name_length);
|
||||
error = writer.StartAlignedEntry(zip_name.c_str(), flags, alignment);
|
||||
if (error != 0) {
|
||||
fprintf(stderr, "StartAlignedEntry failed: %s\n", ZipWriter::ErrorCodeString(error));
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<ZipArchiveStreamEntry> stream(
|
||||
ZipArchiveStreamEntry::Create(handle, *zip_entry));
|
||||
const std::vector<uint8_t>* data;
|
||||
while ((data = stream->Read()) != nullptr) {
|
||||
error = writer.WriteBytes(data->data(), data->size());
|
||||
if (error != 0) {
|
||||
fprintf(stderr, "WriteBytes failed: %s\n", ZipWriter::ErrorCodeString(error));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!stream->Verify()) {
|
||||
fprintf(stderr, "Failed to verify zip stream writer entry.\n");
|
||||
return false;
|
||||
}
|
||||
error = writer.FinishEntry();
|
||||
if (error != 0) {
|
||||
fprintf(stderr, "FinishEntry failed: %s\n", ZipWriter::ErrorCodeString(error));
|
||||
}
|
||||
}
|
||||
|
||||
error = writer.Finish();
|
||||
if (error != 0) {
|
||||
fprintf(stderr, "Finish failed: %s\n", ZipWriter::ErrorCodeString(error));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 4) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* end;
|
||||
unsigned long int alignment = strtoul(argv[1], &end, 10);
|
||||
if ((alignment == ULONG_MAX && errno == ERANGE) || *end != '\0') {
|
||||
fprintf(stderr, "ALIGNMENT value is not a valid number: %s\n", argv[1]);
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
if (((alignment - 1) & alignment) != 0) {
|
||||
fprintf(stderr, "ALIGNMENT value is not a power of 2: %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ZipArchiveHandle handle;
|
||||
|
||||
int32_t return_value = OpenArchive(argv[2], &handle);
|
||||
if (return_value != 0) {
|
||||
CloseArchive(handle);
|
||||
fprintf(stderr, "Unable to open '%s': %s\n", argv[2], ErrorCodeString(return_value));
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* zip_dst = fopen(argv[3], "we");
|
||||
if (zip_dst == nullptr) {
|
||||
fprintf(stderr, "Unable to create '%s': %s\n", argv[3], strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool success = CreateAlignedZip(handle, zip_dst, static_cast<uint32_t>(alignment));
|
||||
|
||||
CloseArchive(handle);
|
||||
fclose(zip_dst);
|
||||
|
||||
return success ? 0 : 1;
|
||||
}
|
4
android/bionic/tests/libs/cfi_test_bad_lib.cpp
Normal file
4
android/bionic/tests/libs/cfi_test_bad_lib.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Mock an invalid CFI-enabled library.
|
||||
__attribute__((aligned(4096))) extern "C" char dummy[16] = {};
|
||||
__asm__(".globl __cfi_check");
|
||||
__asm__("__cfi_check = dummy + 3"); // Not aligned to anything.
|
54
android/bionic/tests/libs/cfi_test_helper.cpp
Normal file
54
android/bionic/tests/libs/cfi_test_helper.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libs_utils.h"
|
||||
|
||||
// This library is built for all targets, including host tests, so __cfi_slowpath may not be
|
||||
// present. But it is only used in the bionic loader tests.
|
||||
extern "C" __attribute__((weak)) void __cfi_slowpath(uint64_t, void*);
|
||||
|
||||
static int g_count;
|
||||
|
||||
// Mock a CFI-enabled library without relying on the compiler.
|
||||
extern "C" __attribute__((aligned(4096))) void __cfi_check(uint64_t /*CallSiteTypeId*/,
|
||||
void* /*TargetAddr*/, void* /*Diag*/) {
|
||||
++g_count;
|
||||
}
|
||||
|
||||
void preinit_ctor() {
|
||||
CHECK(g_count == 0);
|
||||
__cfi_slowpath(42, reinterpret_cast<void*>(&preinit_ctor));
|
||||
CHECK(g_count == 1);
|
||||
}
|
||||
|
||||
__attribute__((section(".preinit_array"), used)) void (*preinit_ctor_p)(void) = preinit_ctor;
|
||||
|
||||
__attribute__((constructor, used)) void ctor() {
|
||||
CHECK(g_count == 1);
|
||||
__cfi_slowpath(42, reinterpret_cast<void*>(&ctor));
|
||||
CHECK(g_count == 2);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
CHECK(g_count == 2);
|
||||
__cfi_slowpath(42, reinterpret_cast<void*>(&main));
|
||||
CHECK(g_count == 3);
|
||||
return 0;
|
||||
}
|
29
android/bionic/tests/libs/cfi_test_helper2.cpp
Normal file
29
android/bionic/tests/libs/cfi_test_helper2.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <assert.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "libs_utils.h"
|
||||
|
||||
int main(void) {
|
||||
void* handle;
|
||||
// libcfi-test.so does some basic testing in a global constructor. Check that it is linked.
|
||||
handle = dlopen("libcfi-test.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
CHECK(handle != nullptr);
|
||||
dlclose(handle);
|
||||
return 0;
|
||||
}
|
87
android/bionic/tests/libs/cfi_test_lib.cpp
Normal file
87
android/bionic/tests/libs/cfi_test_lib.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// This library is built for all targets, including host tests, so __cfi_slowpath may not be
|
||||
// present. But it is only used in the bionic loader tests.
|
||||
extern "C" __attribute__((weak)) void __cfi_slowpath(uint64_t, void*);
|
||||
|
||||
static size_t g_count;
|
||||
static uint64_t g_last_type_id;
|
||||
static void* g_last_address;
|
||||
static void* g_last_diag;
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Make sure the library crosses at least one kLibraryAlignment(=256KB) boundary.
|
||||
char bss[1024 * 1024];
|
||||
|
||||
// Mock a CFI-enabled library without relying on the compiler.
|
||||
__attribute__((aligned(4096))) void __cfi_check(uint64_t CallSiteTypeId, void* TargetAddr,
|
||||
void* Diag) {
|
||||
++g_count;
|
||||
g_last_type_id = CallSiteTypeId;
|
||||
g_last_address = TargetAddr;
|
||||
g_last_diag = Diag;
|
||||
}
|
||||
|
||||
size_t get_count() {
|
||||
return g_count;
|
||||
}
|
||||
|
||||
uint64_t get_last_type_id() {
|
||||
return g_last_type_id;
|
||||
}
|
||||
|
||||
void* get_last_address() {
|
||||
return g_last_address;
|
||||
}
|
||||
|
||||
void* get_last_diag() {
|
||||
return g_last_diag;
|
||||
}
|
||||
|
||||
void* get_global_address() {
|
||||
return &g_count;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that CFI is set up in module constructors and destructors.
|
||||
struct A {
|
||||
void check_cfi_self() {
|
||||
g_last_type_id = 0;
|
||||
assert(&__cfi_slowpath);
|
||||
// CFI check for an invalid address. Normally, this would kill the process by routing the call
|
||||
// back to the calling module's __cfi_check, which does the right thing based on
|
||||
// -fsanitize-recover / -fsanitize-trap. But this module has custom __cfi_check that does not do
|
||||
// any of that, so the result looks like a passing check.
|
||||
int zz;
|
||||
__cfi_slowpath(13, static_cast<void*>(&zz));
|
||||
assert(g_last_type_id == 13);
|
||||
// CFI check for a libc function. This never goes into this module's __cfi_check, and must pass.
|
||||
__cfi_slowpath(14, reinterpret_cast<void*>(&exit));
|
||||
assert(g_last_type_id == 13);
|
||||
}
|
||||
A() {
|
||||
check_cfi_self();
|
||||
}
|
||||
~A() {
|
||||
check_cfi_self();
|
||||
}
|
||||
} a;
|
36
android/bionic/tests/libs/check_rtld_next_from_library.cpp
Normal file
36
android/bionic/tests/libs/check_rtld_next_from_library.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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 <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void* g_libc_close_ptr;
|
||||
|
||||
static void __attribute__((constructor)) __libc_close_lookup() {
|
||||
g_libc_close_ptr = dlsym(RTLD_NEXT, "close");
|
||||
}
|
||||
|
||||
// A libc function used for RTLD_NEXT
|
||||
// This function in not supposed to be called
|
||||
extern "C" int __attribute__((weak)) close(int) {
|
||||
abort();
|
||||
}
|
||||
|
||||
extern "C" void* get_libc_close_ptr() {
|
||||
return g_libc_close_ptr;
|
||||
}
|
||||
|
||||
|
19
android/bionic/tests/libs/dl_df_1_global.cpp
Normal file
19
android/bionic/tests/libs/dl_df_1_global.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 dl_df_1_global_get_answer_impl() {
|
||||
return 42;
|
||||
}
|
23
android/bionic/tests/libs/dl_df_1_use_global.cpp
Normal file
23
android/bionic/tests/libs/dl_df_1_use_global.cpp
Normal file
|
@ -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.
|
||||
*/
|
||||
|
||||
extern "C" int __attribute__((weak)) dl_df_1_global_get_answer_impl() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int dl_df_1_global_get_answer() {
|
||||
return dl_df_1_global_get_answer_impl();
|
||||
}
|
45
android/bionic/tests/libs/dl_preempt_library_1.cpp
Normal file
45
android/bionic/tests/libs/dl_preempt_library_1.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This one should be preempted by the function
|
||||
// defined in the main executable.
|
||||
extern "C" int __attribute__((weak)) main_global_default_serial() {
|
||||
return 2716057;
|
||||
}
|
||||
|
||||
// Even though this one is defined by the main
|
||||
// executable it should not be preempted
|
||||
// because of protected visibility
|
||||
extern "C" int __attribute__((weak, visibility("protected"))) main_global_protected_serial() {
|
||||
return 3370318;
|
||||
}
|
||||
|
||||
extern "C" int main_global_default_get_serial() {
|
||||
return main_global_default_serial();
|
||||
}
|
||||
|
||||
extern "C" int main_global_protected_get_serial() {
|
||||
return main_global_protected_serial();
|
||||
}
|
||||
|
||||
// Trying to preempt functions from a DT_NEEDED .so
|
||||
extern "C" int lib_global_default_serial() {
|
||||
return 3370318;
|
||||
}
|
||||
|
||||
extern "C" int lib_global_protected_serial() {
|
||||
return 2716057;
|
||||
}
|
37
android/bionic/tests/libs/dl_preempt_library_2.cpp
Normal file
37
android/bionic/tests/libs/dl_preempt_library_2.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// This one should be preempted by the function
|
||||
// defined in libdl_preempt_test_1.so
|
||||
extern "C" int __attribute__((weak)) lib_global_default_serial() {
|
||||
return 2716057;
|
||||
}
|
||||
|
||||
// Even though this one is defined by
|
||||
// libdl_preempt_test_1.so it should not be
|
||||
// preempted because of protected visibility
|
||||
extern "C" int __attribute__((weak,visibility("protected"))) lib_global_protected_serial() {
|
||||
return 3370318;
|
||||
}
|
||||
|
||||
extern "C" int lib_global_default_get_serial() {
|
||||
return lib_global_default_serial();
|
||||
}
|
||||
|
||||
extern "C" int lib_global_protected_get_serial() {
|
||||
return lib_global_protected_serial();
|
||||
}
|
||||
|
43
android/bionic/tests/libs/dlext_test_library.cpp
Normal file
43
android/bionic/tests/libs/dlext_test_library.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
public:
|
||||
virtual int getRandomNumber() {
|
||||
return 4; // chosen by fair dice roll.
|
||||
// guaranteed to be random.
|
||||
}
|
||||
|
||||
virtual ~A() {}
|
||||
};
|
||||
|
||||
A a;
|
||||
|
||||
// nested macros to make it easy to define a large amount of read-only data
|
||||
// which will require relocation.
|
||||
#define A_16 &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a, &a,
|
||||
#define A_128 A_16 A_16 A_16 A_16 A_16 A_16 A_16 A_16
|
||||
#define A_1024 A_128 A_128 A_128 A_128 A_128 A_128 A_128 A_128
|
||||
|
||||
extern "C" A* const lots_of_relro[] = {
|
||||
A_1024 A_1024 A_1024 A_1024 A_1024 A_1024 A_1024 A_1024
|
||||
};
|
||||
|
||||
extern "C" int getRandomNumber() {
|
||||
// access the relro section (twice, in fact, once for the pointer, and once
|
||||
// for the vtable of A) to check it's actually there.
|
||||
return lots_of_relro[0]->getRandomNumber();
|
||||
}
|
23
android/bionic/tests/libs/dlopen_2_parents_reloc_answer.cpp
Normal file
23
android/bionic/tests/libs/dlopen_2_parents_reloc_answer.cpp
Normal file
|
@ -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.
|
||||
*/
|
||||
|
||||
extern "C" int __attribute__((weak)) check_order_reloc_get_answer_impl() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int check_order_reloc_get_answer() {
|
||||
return check_order_reloc_get_answer_impl();
|
||||
}
|
16
android/bionic/tests/libs/dlopen_b.cpp
Normal file
16
android/bionic/tests/libs/dlopen_b.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <dlfcn.h>
|
||||
extern "C" void *dlopen_b() {
|
||||
// TODO (dimitry): this is to work around http://b/20049306
|
||||
// remove once it is fixed
|
||||
static int dummy = 0;
|
||||
|
||||
// This is supposed to succeed because this library has DT_RUNPATH
|
||||
// for libtest_dt_runpath_x.so which should be taken into account
|
||||
// by dlopen.
|
||||
void *handle = dlopen("libtest_dt_runpath_x.so", RTLD_NOW);
|
||||
if (handle != nullptr) {
|
||||
dummy++;
|
||||
return handle;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
28
android/bionic/tests/libs/dlopen_check_init_fini_child.cpp
Normal file
28
android/bionic/tests/libs/dlopen_check_init_fini_child.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <string>
|
||||
|
||||
// These two function are called by local group's constructors and destructors
|
||||
extern "C" __attribute__((weak)) void record_init(int digit);
|
||||
extern "C" __attribute__((weak)) void record_fini(const char* s);
|
||||
|
||||
static void __attribute__((constructor)) init() {
|
||||
record_init(2);
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) fini() {
|
||||
record_fini("(child)");
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <string>
|
||||
|
||||
// These two function are called by local group's constructors and destructors
|
||||
extern "C" __attribute__((weak)) void record_init(int digit);
|
||||
extern "C" __attribute__((weak)) void record_fini(const char* s);
|
||||
|
||||
static void __attribute__((constructor)) init() {
|
||||
record_init(3);
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) fini() {
|
||||
record_fini("(grandchild)");
|
||||
}
|
46
android/bionic/tests/libs/dlopen_check_init_fini_root.cpp
Normal file
46
android/bionic/tests/libs/dlopen_check_init_fini_root.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <string>
|
||||
|
||||
static int volatile g_initialization_order_code;
|
||||
|
||||
void (*g_fini_callback)(const char*) = nullptr;
|
||||
|
||||
// These two function are called by local group's constructors and destructors
|
||||
extern "C" void record_init(int digit) {
|
||||
g_initialization_order_code = g_initialization_order_code*10 + digit;
|
||||
}
|
||||
|
||||
extern "C" void record_fini(const char* s) {
|
||||
g_fini_callback(s);
|
||||
}
|
||||
|
||||
// these 2 functions are used by the test
|
||||
extern "C" int get_init_order_number() {
|
||||
return g_initialization_order_code;
|
||||
}
|
||||
|
||||
extern "C" void set_fini_callback(void (*f)(const char*)) {
|
||||
g_fini_callback = f;
|
||||
}
|
||||
|
||||
static void __attribute__((constructor)) init() {
|
||||
record_init(1);
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) fini() {
|
||||
record_fini("(root)");
|
||||
}
|
|
@ -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 check_order_dlsym_get_answer() {
|
||||
return __ANSWER;
|
||||
}
|
||||
|
||||
#ifdef __ANSWER2
|
||||
extern "C" int check_order_dlsym_get_answer2() {
|
||||
return __ANSWER2;
|
||||
}
|
||||
#endif
|
|
@ -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.
|
||||
*/
|
||||
|
||||
extern "C" int __attribute__((weak)) check_order_reloc_get_answer_impl() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int check_order_reloc_get_answer() {
|
||||
return check_order_reloc_get_answer_impl();
|
||||
}
|
|
@ -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 check_order_reloc_get_answer_impl() {
|
||||
return __ANSWER;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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 check_order_reloc_grandchild_get_answer_impl();
|
||||
|
||||
extern "C" int check_order_reloc_grandchild_get_answer() {
|
||||
return check_order_reloc_grandchild_get_answer_impl();
|
||||
}
|
||||
|
|
@ -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 check_order_reloc_grandchild_get_answer_impl() {
|
||||
return __ANSWER;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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 check_order_reloc_get_answer_impl();
|
||||
|
||||
extern "C" int check_order_reloc_nephew_get_answer() {
|
||||
return check_order_reloc_get_answer_impl();
|
||||
}
|
||||
|
||||
namespace {
|
||||
// The d-tor for this class is called on dlclose() -> __on_dlclose() -> __cxa_finalize()
|
||||
// We use it to detect calls to prematurely unmapped libraries during dlclose.
|
||||
// See also b/18338888
|
||||
class CallNephewInDtor {
|
||||
public:
|
||||
~CallNephewInDtor() {
|
||||
check_order_reloc_get_answer_impl();
|
||||
}
|
||||
} instance;
|
||||
};
|
||||
|
||||
extern "C" void* get_instance() {
|
||||
return &instance;
|
||||
}
|
|
@ -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 check_order_reloc_root_get_answer_impl();
|
||||
|
||||
extern "C" int check_order_reloc_root_get_answer() {
|
||||
return check_order_reloc_root_get_answer_impl();
|
||||
}
|
|
@ -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 check_order_reloc_root_get_answer_impl() {
|
||||
return __ANSWER;
|
||||
}
|
31
android/bionic/tests/libs/dlopen_nodelete_1.cpp
Normal file
31
android/bionic/tests/libs/dlopen_nodelete_1.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t dlopen_nodelete_1_taxicab_number = 1729;
|
||||
static bool* unload_flag_ptr = nullptr;
|
||||
|
||||
extern "C" void dlopen_nodelete_1_set_unload_flag_ptr(bool* ptr) {
|
||||
unload_flag_ptr = ptr;
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) unload_guard() {
|
||||
if (unload_flag_ptr != nullptr) {
|
||||
*unload_flag_ptr = true;
|
||||
}
|
||||
}
|
31
android/bionic/tests/libs/dlopen_nodelete_2.cpp
Normal file
31
android/bionic/tests/libs/dlopen_nodelete_2.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t dlopen_nodelete_2_taxicab_number = 1729;
|
||||
static bool* unload_flag_ptr = nullptr;
|
||||
|
||||
extern "C" void dlopen_nodelete_2_set_unload_flag_ptr(bool* ptr) {
|
||||
unload_flag_ptr = ptr;
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) unload_guard() {
|
||||
if (unload_flag_ptr != nullptr) {
|
||||
*unload_flag_ptr = true;
|
||||
}
|
||||
}
|
30
android/bionic/tests/libs/dlopen_nodelete_dt_flags_1.cpp
Normal file
30
android/bionic/tests/libs/dlopen_nodelete_dt_flags_1.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static bool* unload_flag_ptr = nullptr;
|
||||
|
||||
extern "C" void dlopen_nodelete_dt_flags_1_set_unload_flag_ptr(bool* ptr) {
|
||||
unload_flag_ptr = ptr;
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) unload_guard() {
|
||||
if (unload_flag_ptr != nullptr) {
|
||||
*unload_flag_ptr = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 <dlfcn.h>
|
||||
|
||||
static void __attribute__((constructor)) call_dlopen_from_ctor() {
|
||||
void* handle = dlopen("libc.so", RTLD_NOW);
|
||||
dlclose(handle);
|
||||
}
|
||||
|
69
android/bionic/tests/libs/dlopen_testlib_ifunc.cpp
Normal file
69
android/bionic/tests/libs/dlopen_testlib_ifunc.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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 <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static uintptr_t g_flag = 0;
|
||||
|
||||
static void __attribute__((constructor)) init_flag() {
|
||||
g_flag = reinterpret_cast<uintptr_t>(dlsym(RTLD_DEFAULT, "dlsym"));
|
||||
}
|
||||
|
||||
static const char* is_ctor_called() __attribute__ ((ifunc("is_ctor_called_ifun")));
|
||||
|
||||
extern "C" const char* foo() __attribute__ ((ifunc ("foo_ifunc")));
|
||||
|
||||
// Static linker creates GLOBAL/IFUNC symbol and JUMP_SLOT relocation type for plt segment
|
||||
extern "C" const char* is_ctor_called_jump_slot() __attribute__ ((ifunc("is_ctor_called_ifun")));
|
||||
|
||||
extern "C" const char* is_ctor_called_irelative() {
|
||||
// Call internal ifunc-resolved function with IRELATIVE reloc
|
||||
return is_ctor_called();
|
||||
}
|
||||
|
||||
extern "C" const char* return_true() {
|
||||
return "true";
|
||||
}
|
||||
|
||||
extern "C" const char* return_false() {
|
||||
return "false";
|
||||
}
|
||||
|
||||
extern "C" const char* f1() {
|
||||
return "unset";
|
||||
}
|
||||
|
||||
extern "C" const char* f2() {
|
||||
return "set";
|
||||
}
|
||||
|
||||
typedef const char* (*fn_ptr)();
|
||||
|
||||
extern "C" fn_ptr is_ctor_called_ifun() {
|
||||
return g_flag == 0 ? return_false : return_true;
|
||||
}
|
||||
|
||||
extern "C" fn_ptr foo_ifunc() {
|
||||
char* choice = getenv("IFUNC_CHOICE");
|
||||
return choice == NULL ? f1 : f2;
|
||||
}
|
||||
|
||||
extern "C" const char* foo_library() {
|
||||
return foo();
|
||||
}
|
24
android/bionic/tests/libs/dlopen_testlib_ifunc_variable.cpp
Normal file
24
android/bionic/tests/libs/dlopen_testlib_ifunc_variable.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" const char* foo;
|
||||
|
||||
extern "C" const char* foo_library() {
|
||||
return foo;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static uintptr_t g_flag = 0;
|
||||
|
||||
static void __attribute__((constructor)) init_flag() {
|
||||
g_flag = reinterpret_cast<uintptr_t>(dlsym(RTLD_DEFAULT, "dlsym"));
|
||||
}
|
||||
|
||||
static const char* is_ctor_called() __attribute__ ((ifunc("is_ctor_called_ifun")));
|
||||
|
||||
extern "C" const char* foo() __attribute__ ((ifunc ("foo_ifunc")));
|
||||
|
||||
// Static linker creates GLOBAL/IFUNC symbol and JUMP_SLOT relocation type for plt segment
|
||||
extern "C" const char* is_ctor_called_jump_slot() __attribute__ ((ifunc("is_ctor_called_ifun")));
|
||||
|
||||
extern "C" const char* is_ctor_called_irelative() {
|
||||
// Call internal ifunc-resolved function with IRELATIVE reloc
|
||||
return is_ctor_called();
|
||||
}
|
||||
|
||||
extern "C" const char* var_true = "true";
|
||||
extern "C" const char* var_false = "false";
|
||||
|
||||
extern "C" const char* v1 = "unset";
|
||||
extern "C" const char* v2 = "set";
|
||||
|
||||
extern "C" void* is_ctor_called_ifun() {
|
||||
return g_flag == 0 ? &var_false : &var_true;
|
||||
}
|
||||
|
||||
extern "C" void* foo_ifunc() {
|
||||
char* choice = getenv("IFUNC_CHOICE");
|
||||
return choice == NULL ? &v1 : &v2;
|
||||
}
|
25
android/bionic/tests/libs/dlopen_testlib_loopy_a.cpp
Normal file
25
android/bionic/tests/libs/dlopen_testlib_loopy_a.cpp
Normal file
|
@ -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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" bool __attribute__((weak)) dlopen_test_loopy_function_impl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" bool dlopen_test_loopy_function() {
|
||||
return dlopen_test_loopy_function_impl();
|
||||
}
|
21
android/bionic/tests/libs/dlopen_testlib_loopy_b.cpp
Normal file
21
android/bionic/tests/libs/dlopen_testlib_loopy_b.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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" bool dlopen_test_loopy_function_impl() {
|
||||
return false;
|
||||
}
|
21
android/bionic/tests/libs/dlopen_testlib_loopy_c.cpp
Normal file
21
android/bionic/tests/libs/dlopen_testlib_loopy_c.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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" bool dlopen_test_loopy_function_impl() {
|
||||
return false;
|
||||
}
|
23
android/bionic/tests/libs/dlopen_testlib_loopy_invalid.cpp
Normal file
23
android/bionic/tests/libs/dlopen_testlib_loopy_invalid.cpp
Normal file
|
@ -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>
|
||||
|
||||
// This library should never be loaded
|
||||
static void __attribute__((constructor)) panic() {
|
||||
abort();
|
||||
}
|
||||
|
21
android/bionic/tests/libs/dlopen_testlib_loopy_root.cpp
Normal file
21
android/bionic/tests/libs/dlopen_testlib_loopy_root.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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" bool dlopen_test_loopy_function_impl() {
|
||||
return true;
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
24
android/bionic/tests/libs/dlopen_testlib_simple.cpp
Normal file
24
android/bionic/tests/libs/dlopen_testlib_simple.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t dlopen_testlib_taxicab_number = 1729;
|
||||
|
||||
extern "C" bool dlopen_testlib_simple_func() {
|
||||
return true;
|
||||
}
|
25
android/bionic/tests/libs/dlopen_weak_undefined.cpp
Normal file
25
android/bionic/tests/libs/dlopen_weak_undefined.cpp
Normal file
|
@ -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 __attribute__((weak)) weak_undefined_func();
|
||||
|
||||
extern "C" int use_weak_undefined_func() {
|
||||
if (weak_undefined_func) {
|
||||
return weak_undefined_func();
|
||||
} else {
|
||||
return 6551;
|
||||
}
|
||||
}
|
52
android/bionic/tests/libs/dlsym_from_this_functions.cpp
Normal file
52
android/bionic/tests/libs/dlsym_from_this_functions.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int test_dlsym_symbol;
|
||||
|
||||
int test_dlsym_symbol = -1;
|
||||
|
||||
extern "C" int* lookup_dlsym_symbol_using_RTLD_DEFAULT() {
|
||||
dlerror();
|
||||
int* result = static_cast<int*>(dlsym(RTLD_DEFAULT, "test_dlsym_symbol"));
|
||||
// TODO: remove this once b/20049306 is fixed
|
||||
if (result == nullptr) {
|
||||
printf("Cannot find the answer\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" int* lookup_dlsym_symbol2_using_RTLD_DEFAULT() {
|
||||
dlerror();
|
||||
int* result = static_cast<int*>(dlsym(RTLD_DEFAULT, "test_dlsym_symbol2"));
|
||||
// TODO: remove this once b/20049306 is fixed
|
||||
if (result == nullptr) {
|
||||
printf("Cannot find the answer\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" int* lookup_dlsym_symbol_using_RTLD_NEXT() {
|
||||
dlerror();
|
||||
int* result = static_cast<int*>(dlsym(RTLD_NEXT, "test_dlsym_symbol"));
|
||||
// TODO: remove this once b/20049306 is fixed
|
||||
if (result == nullptr) {
|
||||
printf("Cannot find the answer\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
17
android/bionic/tests/libs/dlsym_from_this_symbol.cpp
Normal file
17
android/bionic/tests/libs/dlsym_from_this_symbol.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
int test_dlsym_symbol = 42;
|
18
android/bionic/tests/libs/dlsym_from_this_symbol2.cpp
Normal file
18
android/bionic/tests/libs/dlsym_from_this_symbol2.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
int test_dlsym_symbol = 43;
|
||||
int test_dlsym_symbol2 = 44;
|
20
android/bionic/tests/libs/dlsym_weak_function.cpp
Normal file
20
android/bionic/tests/libs/dlsym_weak_function.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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 __attribute__((weak)) weak_func() {
|
||||
return 42;
|
||||
}
|
||||
|
0
android/bionic/tests/libs/empty.cpp
Normal file
0
android/bionic/tests/libs/empty.cpp
Normal file
26
android/bionic/tests/libs/ld_config_test_helper.cpp
Normal file
26
android/bionic/tests/libs/ld_config_test_helper.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int get_value_from_lib();
|
||||
|
||||
int main() {
|
||||
printf("%d", get_value_from_lib());
|
||||
return 0;
|
||||
}
|
4
android/bionic/tests/libs/ld_config_test_helper_lib1.cpp
Normal file
4
android/bionic/tests/libs/ld_config_test_helper_lib1.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
extern int get_value_from_another_lib();
|
||||
int get_value_from_lib() {
|
||||
return get_value_from_another_lib();
|
||||
}
|
3
android/bionic/tests/libs/ld_config_test_helper_lib2.cpp
Normal file
3
android/bionic/tests/libs/ld_config_test_helper_lib2.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
int get_value_from_another_lib() {
|
||||
return 12345;
|
||||
}
|
3
android/bionic/tests/libs/ld_config_test_helper_lib3.cpp
Normal file
3
android/bionic/tests/libs/ld_config_test_helper_lib3.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
int get_value_from_another_lib() {
|
||||
return 54321;
|
||||
}
|
26
android/bionic/tests/libs/ld_preload_test_helper.cpp
Normal file
26
android/bionic/tests/libs/ld_preload_test_helper.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int get_value_from_lib();
|
||||
|
||||
int main() {
|
||||
printf("%d", get_value_from_lib());
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
int get_value_from_lib() {
|
||||
return 12345;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
int get_value_from_lib() {
|
||||
return 54321;
|
||||
}
|
27
android/bionic/tests/libs/libs_utils.h
Normal file
27
android/bionic/tests/libs/libs_utils.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*/
|
||||
|
||||
#ifndef LIBS_UTILS_H
|
||||
#define LIBS_UTILS_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CHECK(e) \
|
||||
((e) ? static_cast<void>(0) : __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))
|
||||
|
||||
#endif // LIBS_UTILS_H
|
19
android/bionic/tests/libs/namespaces_dlopened.cpp
Normal file
19
android/bionic/tests/libs/namespaces_dlopened.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
const char* g_private_dlopened_string = "This string is from private namespace "
|
||||
"(dlopened library)";
|
||||
|
18
android/bionic/tests/libs/namespaces_private.cpp
Normal file
18
android/bionic/tests/libs/namespaces_private.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
const char* g_private_extern_string = "This string is from private namespace";
|
||||
|
18
android/bionic/tests/libs/namespaces_public.cpp
Normal file
18
android/bionic/tests/libs/namespaces_public.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
const char* g_public_extern_string = "This string is from public namespace";
|
||||
|
21
android/bionic/tests/libs/namespaces_public_internal.cpp
Normal file
21
android/bionic/tests/libs/namespaces_public_internal.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*/
|
||||
|
||||
static const char* g_internal_extern_string = "This string is from a library a shared library depends on";
|
||||
|
||||
extern "C" const char* internal_extern_string() {
|
||||
return g_internal_extern_string;
|
||||
}
|
67
android/bionic/tests/libs/namespaces_root.cpp
Normal file
67
android/bionic/tests/libs/namespaces_root.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 <dlfcn.h>
|
||||
|
||||
static const char* g_local_string = "This string is local to root library";
|
||||
extern "C" const char* g_private_extern_string;
|
||||
extern "C" const char* g_public_extern_string;
|
||||
|
||||
// This is resolved only if public library is in the same namespace as
|
||||
// the root one. It should remain unresolved if looking up for public library
|
||||
// crosses namespace boundary.
|
||||
//
|
||||
// Defined in libnstest_public_internal.so on which libnstest_public.so
|
||||
// depends on
|
||||
extern "C" const char* __attribute__((weak)) internal_extern_string();
|
||||
|
||||
bool g_dlopened = false;
|
||||
|
||||
extern "C" const char* ns_get_local_string() {
|
||||
return g_local_string;
|
||||
}
|
||||
|
||||
extern "C" const char* ns_get_private_extern_string() {
|
||||
return g_private_extern_string;
|
||||
}
|
||||
|
||||
extern "C" const char* ns_get_public_extern_string() {
|
||||
return g_public_extern_string;
|
||||
}
|
||||
|
||||
extern "C" const char* ns_get_internal_extern_string() {
|
||||
if (internal_extern_string != nullptr) {
|
||||
return internal_extern_string();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" const char* ns_get_dlopened_string() {
|
||||
void* handle = dlopen("libnstest_dlopened.so", RTLD_NOW | RTLD_GLOBAL);
|
||||
if (handle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char** result = static_cast<const char**>(dlsym(handle, "g_private_dlopened_string"));
|
||||
if (result == nullptr) {
|
||||
return nullptr;
|
||||
} else {
|
||||
g_dlopened = true;
|
||||
}
|
||||
|
||||
return *result;
|
||||
}
|
39
android/bionic/tests/libs/preinit_getauxval_test_helper.cpp
Normal file
39
android/bionic/tests/libs/preinit_getauxval_test_helper.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#include "libs_utils.h"
|
||||
|
||||
static unsigned long g_AT_RANDOM;
|
||||
static unsigned long g_AT_PAGESZ;
|
||||
|
||||
static void preinit_ctor() {
|
||||
g_AT_RANDOM = getauxval(AT_RANDOM);
|
||||
g_AT_PAGESZ = getauxval(AT_PAGESZ);
|
||||
}
|
||||
|
||||
__attribute__((section(".preinit_array"), used)) void (*preinit_ctor_p)(void) = preinit_ctor;
|
||||
|
||||
int main() {
|
||||
// Did getauxval during preinit get the same results as getauxval now?
|
||||
CHECK(getauxval(AT_RANDOM) == g_AT_RANDOM);
|
||||
CHECK(getauxval(AT_PAGESZ) == g_AT_PAGESZ);
|
||||
return 0;
|
||||
}
|
40
android/bionic/tests/libs/preinit_syscall_test_helper.cpp
Normal file
40
android/bionic/tests/libs/preinit_syscall_test_helper.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#include "libs_utils.h"
|
||||
|
||||
static ssize_t g_result;
|
||||
static int g_errno;
|
||||
|
||||
static void preinit_ctor() {
|
||||
// Can we make a system call?
|
||||
g_result = write(-1, "", 1);
|
||||
g_errno = errno;
|
||||
}
|
||||
|
||||
__attribute__((section(".preinit_array"), used)) void (*preinit_ctor_p)(void) = preinit_ctor;
|
||||
|
||||
int main() {
|
||||
// Did we get the expected failure?
|
||||
CHECK(g_result == -1);
|
||||
CHECK(g_errno == EBADF);
|
||||
return 0;
|
||||
}
|
21
android/bionic/tests/libs/pthread_atfork.cpp
Normal file
21
android/bionic/tests/libs/pthread_atfork.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.
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
extern "C" int proxy_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) {
|
||||
return pthread_atfork(prepare, parent, child);
|
||||
}
|
21
android/bionic/tests/libs/versioned_lib_other.cpp
Normal file
21
android/bionic/tests/libs/versioned_lib_other.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 versioned_function_v2() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
__asm__(".symver versioned_function_v2,versioned_function@@TESTLIB_V2");
|
9
android/bionic/tests/libs/versioned_lib_other.map
Normal file
9
android/bionic/tests/libs/versioned_lib_other.map
Normal file
|
@ -0,0 +1,9 @@
|
|||
TESTLIB_V0 {
|
||||
local:
|
||||
versioned_function_v*;
|
||||
};
|
||||
|
||||
TESTLIB_V2 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V0;
|
30
android/bionic/tests/libs/versioned_lib_v1.cpp
Normal file
30
android/bionic/tests/libs/versioned_lib_v1.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 versioned_function_v1(); // __attribute__((visibility("hidden")));
|
||||
int version_zero_function();
|
||||
}
|
||||
|
||||
int versioned_function_v1() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int version_zero_function() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
__asm__(".symver versioned_function_v1,versioned_function@@TESTLIB_V1");
|
12
android/bionic/tests/libs/versioned_lib_v1.map
Normal file
12
android/bionic/tests/libs/versioned_lib_v1.map
Normal file
|
@ -0,0 +1,12 @@
|
|||
TESTLIB_V0 {
|
||||
global:
|
||||
version_zero_function;
|
||||
local:
|
||||
versioned_function_v*;
|
||||
};
|
||||
|
||||
TESTLIB_V1 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V0;
|
||||
|
35
android/bionic/tests/libs/versioned_lib_v2.cpp
Normal file
35
android/bionic/tests/libs/versioned_lib_v2.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 versioned_function_v1(); // __attribute__((visibility("hidden")));
|
||||
int versioned_function_v2(); // __attribute__((visibility("hidden")));
|
||||
int version_zero_function();
|
||||
}
|
||||
|
||||
int versioned_function_v1() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int versioned_function_v2() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int version_zero_function() {
|
||||
return 200;
|
||||
}
|
||||
__asm__(".symver versioned_function_v1,versioned_function@TESTLIB_V1");
|
||||
__asm__(".symver versioned_function_v2,versioned_function@@TESTLIB_V2");
|
16
android/bionic/tests/libs/versioned_lib_v2.map
Normal file
16
android/bionic/tests/libs/versioned_lib_v2.map
Normal file
|
@ -0,0 +1,16 @@
|
|||
TESTLIB_V0 {
|
||||
global:
|
||||
version_zero_function;
|
||||
local:
|
||||
versioned_function_v*;
|
||||
};
|
||||
|
||||
TESTLIB_V1 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V0;
|
||||
|
||||
TESTLIB_V2 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V1;
|
42
android/bionic/tests/libs/versioned_lib_v3.cpp
Normal file
42
android/bionic/tests/libs/versioned_lib_v3.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 versioned_function_v1(); // __attribute__((visibility("hidden")));
|
||||
int versioned_function_v2(); // __attribute__((visibility("hidden")));
|
||||
int versioned_function_v3(); // __attribute__((visibility("hidden")));
|
||||
int version_zero_function();
|
||||
}
|
||||
|
||||
int versioned_function_v1() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int versioned_function_v2() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int versioned_function_v3() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
int version_zero_function() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
__asm__(".symver versioned_function_v1,versioned_function@TESTLIB_V1");
|
||||
__asm__(".symver versioned_function_v2,versioned_function@TESTLIB_V2");
|
||||
__asm__(".symver versioned_function_v3,versioned_function@@TESTLIB_V3");
|
21
android/bionic/tests/libs/versioned_lib_v3.map
Normal file
21
android/bionic/tests/libs/versioned_lib_v3.map
Normal file
|
@ -0,0 +1,21 @@
|
|||
TESTLIB_V0 {
|
||||
global:
|
||||
version_zero_function;
|
||||
local:
|
||||
versioned_function_v*;
|
||||
};
|
||||
|
||||
TESTLIB_V1 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V0;
|
||||
|
||||
TESTLIB_V2 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V1;
|
||||
|
||||
TESTLIB_V3 {
|
||||
global:
|
||||
versioned_function;
|
||||
} TESTLIB_V2;
|
32
android/bionic/tests/libs/versioned_uselib.cpp
Normal file
32
android/bionic/tests/libs/versioned_uselib.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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 versioned_function();
|
||||
|
||||
int get_function_version();
|
||||
int version_zero_function();
|
||||
int version_zero_function2() __attribute__((weak));
|
||||
}
|
||||
|
||||
int get_function_version() {
|
||||
return version_zero_function2() + version_zero_function() + versioned_function();
|
||||
}
|
||||
|
||||
// we expect this function to be preempted by main executable.
|
||||
int version_zero_function2() {
|
||||
return 40000;
|
||||
}
|
9
android/bionic/tests/libs/versioned_uselib.map
Normal file
9
android/bionic/tests/libs/versioned_uselib.map
Normal file
|
@ -0,0 +1,9 @@
|
|||
TESTLIB_NONE {
|
||||
global:
|
||||
get_function_version;
|
||||
};
|
||||
|
||||
TESTLIB_ZERO {
|
||||
global:
|
||||
version_zero_function2;
|
||||
} TESTLIB_NONE;
|
Loading…
Add table
Add a link
Reference in a new issue