linker: add android_get_exported_namespace
Depending on how ld.config.txt is configured, there can be multiple
built-in namespaces created by the linker from the beginning of a
process. android_get_exported_namespace is a platform only API for
getting a handle (android_namespace_t*) to one of the built-in namespaces
with given name. The returned namespace can then be given to
android_dlopen_ext in order to explicitly specify the target namespace
where the library is searched and loaded from.
Note that this function only returns 'exported' namespaces created via
ld.config.txt file. In order to export a namespace, the visible property
should be set to true:
namespace.<name>.visible = true
Namespaces are hidden by default. Hidden namespaces and namespaces
that are created programmatically, notably 'classloader-namespace',
aren't returned by this function.
Bug: 36851137
Test: confirmed that namespaces created with ld.config.txt is retrieved.
Test: linker-unit-tests passes
Merged-in: I714b510fa24f77e42c3dfc4c827b3befa8bb2951
Change-Id: I0d05fa7e0e116009edf8ea362ab46774bc617cbf
(cherry picked from commit d7c4832e6a640be972017e85ab21e72950dfeddd)
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 0bc5a31..6195d40 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -214,6 +214,10 @@
return success;
}
+android_namespace_t* __android_get_exported_namespace(const char* name) {
+ return get_exported_namespace(name);
+}
+
void __cfi_fail(uint64_t CallSiteTypeId, void* Ptr, void *DiagData, void *CallerPc) {
CFIShadowWriter::CfiFail(CallSiteTypeId, Ptr, DiagData, CallerPc);
}
@@ -256,9 +260,13 @@
// 4*
// 0000000 000111111111122222222223333 333333444444444455 555555556666666666777777777788888 888889999999999
// 0123456 789012345678901234567890123 456789012345678901 234567890123456789012345678901234 567890123456789
- "dlvsym\0__loader_android_dlwarning\0__loader_cfi_fail\0__loader_android_link_namespaces\0"
+ "dlvsym\0__loader_android_dlwarning\0__loader_cfi_fail\0__loader_android_link_namespaces\0__loader_androi"
+ // 5*
+ // 0000000000111111111122222 22222
+ // 0123456789012345678901234 56789
+ "d_get_exported_namespace\0"
#if defined(__arm__)
- // 485
+ // 525
"__loader_dl_unwind_find_exidx\0"
#endif
;
@@ -286,8 +294,9 @@
ELFW(SYM_INITIALIZER)(407, &__android_dlwarning, 1),
ELFW(SYM_INITIALIZER)(434, &__cfi_fail, 1),
ELFW(SYM_INITIALIZER)(452, &__android_link_namespaces, 1),
+ ELFW(SYM_INITIALIZER)(485, &__android_get_exported_namespace, 1),
#if defined(__arm__)
- ELFW(SYM_INITIALIZER)(485, &__dl_unwind_find_exidx, 1),
+ ELFW(SYM_INITIALIZER)(525, &__dl_unwind_find_exidx, 1),
#endif
};
@@ -304,9 +313,9 @@
// Note that adding any new symbols here requires stubbing them out in libdl.
static unsigned g_libdl_buckets[1] = { 1 };
#if defined(__arm__)
-static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0 };
+static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0 };
#else
-static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0 };
+static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0 };
#endif
static uint8_t __libdl_info_buf[sizeof(soinfo)] __attribute__((aligned(8)));