diff options
author | Jiyong Park <jiyong@google.com> | 2017-05-20 01:01:24 +0900 |
---|---|---|
committer | Jiyong Park <jiyong@google.com> | 2017-08-03 01:02:07 +0900 |
commit | 02586a2a34e6acfccf359b94db840f422b6c0231 (patch) | |
tree | 9dde1a2bcf8a004b23fe41b9f3e497895d44e44d /linker/linker_namespaces.cpp | |
parent | 5ac5a7c0839a123c2982b37b383a7691fd216e7e (diff) |
linker: the global group is added to all built-in namespaces
With ld.config.txt, we now have multiple built-in namespaces other than
the default namespace. Libs (and their dependents) listed in LD_PRELOAD
must be visible to those additional namespaces as well.
This also adds a debugging only feature: path to the linker config file
can be customized via LD_CONFIG_FILE environment variable. This works
only for debuggable builds.
Bug: 38114603
Bug: 62815515
Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib
prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/5.0/lib/linux
2. enable talkback shortcut
3. in the home screen, hold vol-up/down together
4. device does not reboots and talkback shortcut is toggled
Test: bionic-unit-tests and linker-unit-tests successful
Change-Id: I9a03591053f4a9caea82f0dcb23e7a3d324bb9bd
Diffstat (limited to 'linker/linker_namespaces.cpp')
-rw-r--r-- | linker/linker_namespaces.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/linker/linker_namespaces.cpp b/linker/linker_namespaces.cpp index 3c86f9984..9fdf0b51c 100644 --- a/linker/linker_namespaces.cpp +++ b/linker/linker_namespaces.cpp @@ -31,6 +31,8 @@ #include "linker_soinfo.h" #include "linker_utils.h" +#include <dlfcn.h> + bool android_namespace_t::is_accessible(const std::string& file) { if (!is_isolated_) { return true; @@ -86,3 +88,41 @@ bool android_namespace_t::is_accessible(soinfo* s) { return !is_accessible_ftor(si); }); } + +// TODO: this is slightly unusual way to construct +// the global group for relocation. Not every RTLD_GLOBAL +// library is included in this group for backwards-compatibility +// reasons. +// +// This group consists of the main executable, LD_PRELOADs +// and libraries with the DF_1_GLOBAL flag set. +soinfo_list_t android_namespace_t::get_global_group() { + soinfo_list_t global_group; + soinfo_list().for_each([&](soinfo* si) { + if ((si->get_dt_flags_1() & DF_1_GLOBAL) != 0) { + global_group.push_back(si); + } + }); + + return global_group; +} + +// This function provides a list of libraries to be shared +// by the namespace. For the default namespace this is the global +// group (see get_global_group). For all others this is a group +// of RTLD_GLOBAL libraries (which includes the global group from +// the default namespace). +soinfo_list_t android_namespace_t::get_shared_group() { + if (this == &g_default_namespace) { + return get_global_group(); + } + + soinfo_list_t shared_group; + soinfo_list().for_each([&](soinfo* si) { + if ((si->get_rtld_flags() & RTLD_GLOBAL) != 0) { + shared_group.push_back(si); + } + }); + + return shared_group; +} |