aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-04-10 02:29:25 +0900
committerJiyong Park <jiyong@google.com>2019-04-10 02:29:25 +0900
commitff94a13d2d0679ea1ceb60464547237bb59362f7 (patch)
treeaf2ae9ee0ccbd12ee316d51c5f9cc29382043b23
parent478f7f12b31ee4b46271c120c32eceee6854d4d1 (diff)
downloadbionic-ff94a13d2d0679ea1ceb60464547237bb59362f7.tar.gz
Don't load libc_malloc_* libs from runtime ns for libc_scudo
malloc_common_dynamic.cpp is compiled into both libc.so and libc_scudo.so. When compiled for libc_scudo.so, it doesn't try to load libc_malloc_* libs from the runtime linker namespace. This is because, unlike libc.so which is shared from the runtime APEX, libc_scudo.so is copied to any APEX that it needs. Furthermore, libdl_android which provides android_get_exported_namespace is not available for vendors. So the vendor variant of libc_scudo.so can't anyway locate the runtime namespace. Bug: 130213757 Bug: 122566199 Test: `m libc_scudo libc_scudo` is successful Test: inspect the built library to see if it has reference to android_get_exported_namespace Change-Id: I4c41de361fdb3fa34b95218923f4ce4e9c010f9e
-rw-r--r--libc/bionic/malloc_common_dynamic.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index cf25f8ef0..e7147a0e8 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -279,10 +279,17 @@ bool InitSharedLibrary(void* impl_handle, const char* shared_lib, const char* pr
return true;
}
+// Note about USE_SCUDO. This file is compiled into libc.so and libc_scudo.so.
+// When compiled into libc_scudo.so, the libc_malloc_* libraries don't need
+// to be loaded from the runtime namespace since libc_scudo.so is not from
+// the runtime APEX, but is copied to any APEX that needs it.
+#ifndef USE_SCUDO
extern "C" struct android_namespace_t* android_get_exported_namespace(const char* name);
+#endif
void* LoadSharedLibrary(const char* shared_lib, const char* prefix, MallocDispatch* dispatch_table) {
void* impl_handle = nullptr;
+#ifndef USE_SCUDO
// Try to load the libc_malloc_* libs from the "runtime" namespace and then
// fall back to dlopen() to load them from the default namespace.
//
@@ -301,6 +308,7 @@ void* LoadSharedLibrary(const char* shared_lib, const char* prefix, MallocDispat
};
impl_handle = android_dlopen_ext(shared_lib, RTLD_NOW | RTLD_LOCAL, &dlextinfo);
}
+#endif
if (impl_handle == nullptr) {
impl_handle = dlopen(shared_lib, RTLD_NOW | RTLD_LOCAL);