android_bionic/tests/libs
Peter Collingbourne b39cb3c31d linker: Handle libraries with disjoint mappings correctly.
It's possible and sometimes beneficial for a library to have disjoint mappings
and for other libraries to be mapped into the gap between the mappings using
ANDROID_DLEXT_RESERVED_ADDRESS. See for example the proposal for partitioning
in lld [1].

Because the find_containing_library and do_dl_unwind_find_exidx functions use
a simple bounds check to figure out whether a pointer belongs to a library
they will, given a pointer into a library mapped into the gap of a library
with disjoint mappings, return a pointer to the soinfo for the outer library
instead of the inner one, because the outer library will appear before the
inner one in the solist.

From a user perspective this means that we won't be able to unwind the inner
library's frames on 32-bit ARM with libgcc, dladdr() will return information
for the outer library given a pointer to the inner one and dlopen() et al will
use the linker namespace of the outer library when called from the inner one
(although they will usually be the same).

To make this work correctly, make it so that once find_containing_library
sees a match for the bounds check, it examines the library's PT_LOADs to
make sure that there is a mapping for the given address. This is similar
to how libgcc and libunwind_llvm already handle finding the PT_GNU_EH_FRAME
on non-ARM32 platforms [2,3]. do_dl_unwind_find_exidx is reimplemented in
terms of find_containing_library.

[1] http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html
[2] e739ac0e25/libunwind/src/AddressSpace.hpp (L523)
[3] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.9/libgcc/unwind-dw2-fde-dip.c#294

Test: /data/nativetest{,64}/bionic-unit-tests/bionic-unit-tests on walleye-userdebug
Change-Id: I368fe6ad3c470b3dff80f7d9b04253566d63a7d2
2019-03-08 18:34:34 -08:00
..
Android.bp
Android.build.dlext_testzip.mk
Android.build.dlopen_2_parents_reloc.mk
Android.build.dlopen_check_order_dlsym.mk
Android.build.dlopen_check_order_reloc_main_executable.mk
Android.build.dlopen_check_order_reloc_siblings.mk
Android.build.dt_runpath.mk
Android.build.linker_namespaces.mk
Android.build.pthread_atfork.mk
Android.build.testlib.host.mk
Android.build.testlib.internal.mk
Android.build.testlib.mk
Android.build.testlib.target.mk
Android.build.versioned_lib.mk
Android.mk
atexit_testlib.cpp
bionic_tests_zipalign.cpp
cfi_test_bad_lib.cpp
cfi_test_helper.cpp
cfi_test_helper2.cpp
cfi_test_lib.cpp
check_rtld_next_from_library.cpp
dl_df_1_global.cpp
dl_df_1_global_dummy.cpp
dl_df_1_use_global.cpp
dl_preempt_library_1.cpp
dl_preempt_library_2.cpp
dlext_test_library.cpp
dlext_test_recursive_library.cpp
dlopen_2_parents_reloc_answer.cpp
dlopen_b.cpp
dlopen_check_init_fini_child.cpp
dlopen_check_init_fini_grand_child.cpp
dlopen_check_init_fini_root.cpp
dlopen_check_order_dlsym_answer.cpp
dlopen_check_order_reloc_answer.cpp
dlopen_check_order_reloc_answer_impl.cpp
dlopen_check_order_reloc_grandchild_answer.cpp
dlopen_check_order_reloc_grandchild_answer_impl.cpp
dlopen_check_order_reloc_nephew_answer.cpp
dlopen_check_order_reloc_root_answer.cpp
dlopen_check_order_reloc_root_answer_impl.cpp
dlopen_nodelete_1.cpp
dlopen_nodelete_2.cpp
dlopen_nodelete_dt_flags_1.cpp
dlopen_testlib_dlopen_from_ctor.cpp
dlopen_testlib_ifunc.cpp
dlopen_testlib_ifunc_variable.cpp
dlopen_testlib_ifunc_variable_impl.cpp
dlopen_testlib_loopy_a.cpp
dlopen_testlib_loopy_b.cpp
dlopen_testlib_loopy_c.cpp
dlopen_testlib_loopy_invalid.cpp
dlopen_testlib_loopy_root.cpp
dlopen_testlib_missing_symbol.cpp
dlopen_testlib_relo_check_dt_needed_order.cpp
dlopen_testlib_relo_check_dt_needed_order_1.cpp
dlopen_testlib_relo_check_dt_needed_order_2.cpp
dlopen_testlib_simple.cpp
dlopen_weak_undefined.cpp
dlsym_from_this_functions.cpp
dlsym_from_this_symbol.cpp
dlsym_from_this_symbol2.cpp
dlsym_weak_function.cpp
elftls_dlopen_ie_error_helper.cpp
elftls_dynamic.cpp
elftls_dynamic_filler.cpp
elftls_shared_var.cpp
elftls_shared_var_ie.cpp
elftls_tprel.cpp
empty.cpp
exec_linker_helper.cpp
exec_linker_helper_lib.cpp
ld_config_test_helper.cpp
ld_config_test_helper_lib1.cpp
ld_config_test_helper_lib2.cpp
ld_config_test_helper_lib3.cpp
ld_preload_test_helper.cpp
ld_preload_test_helper_lib1.cpp
ld_preload_test_helper_lib2.cpp
libnstest_ns_a_public1.cpp
libnstest_ns_a_public1_internal.cpp
libnstest_ns_b_public2.cpp
libnstest_ns_b_public3.cpp
libs_utils.h
namespaces_dlopened.cpp
namespaces_private.cpp
namespaces_public.cpp
namespaces_public_internal.cpp
namespaces_root.cpp
preinit_getauxval_test_helper.cpp
preinit_syscall_test_helper.cpp
pthread_atfork.cpp
segment_gap_inner.cpp
segment_gap_outer.cpp
segment_gap_outer.lds
thread_local_dtor.cpp
thread_local_dtor2.cpp
versioned_lib_other.cpp
versioned_lib_other.map
versioned_lib_v1.cpp
versioned_lib_v1.map
versioned_lib_v2.cpp
versioned_lib_v2.map
versioned_lib_v3.cpp
versioned_lib_v3.map
versioned_uselib.cpp
versioned_uselib.map