Merge "Replace public library list with shared lib sonames"

This commit is contained in:
Dimitry Ivanov 2017-02-11 19:26:48 +00:00 committed by Gerrit Code Review
commit fd87c062ab
2 changed files with 16 additions and 8 deletions

View file

@ -22,16 +22,15 @@
__BEGIN_DECLS
/*
* Initializes public and anonymous namespaces. The public_ns_sonames is the list of sonames
* to be included into public namespace separated by colon. Example: "libc.so:libm.so:libdl.so".
* The libraries in this list should be loaded prior to this call.
* Initializes anonymous namespaces. The shared_libs_sonames is the list of sonames
* to be shared by default namespace separated by colon. Example: "libc.so:libm.so:libdl.so".
*
* The anon_ns_library_path is the search path for anonymous namespace. The anonymous namespace
* The library_search_path is the search path for anonymous namespace. The anonymous namespace
* is used in the case when linker cannot identify the caller of dlopen/dlsym. This happens
* for the code not loaded by dynamic linker; for example calls from the mono-compiled code.
*/
extern bool android_init_namespaces(const char* public_ns_sonames,
const char* anon_ns_library_path);
extern bool android_init_anonymous_namespace(const char* shared_libs_sonames,
const char* library_search_path);
enum {
@ -86,6 +85,10 @@ extern struct android_namespace_t* android_create_namespace(const char* name,
const char* permitted_when_isolated_path,
android_namespace_t* parent);
extern bool android_link_namespaces(android_namespace_t* from,
android_namespace_t* to,
const char* shared_libs_sonames);
/*
* Get the default library search path.
* The path will be copied into buffer, which must have space for at least

View file

@ -165,6 +165,11 @@ class LibraryNamespaces {
return false;
}
if (!android_link_namespaces(ns, nullptr, public_libraries_.c_str())) {
*error_msg = dlerror();
return false;
}
native_loader_ns = NativeLoaderNamespace(ns);
} else {
native_bridge_namespace_t* ns = NativeBridgeCreateNamespace("classloader-namespace",
@ -310,8 +315,8 @@ class LibraryNamespaces {
// code is one example) unknown to linker in which case linker uses anonymous
// namespace. The second argument specifies the search path for the anonymous
// namespace which is the library_path of the classloader.
initialized_ = android_init_namespaces(public_libraries_.c_str(),
is_native_bridge ? nullptr : library_path);
initialized_ = android_init_anonymous_namespace(public_libraries_.c_str(),
is_native_bridge ? nullptr : library_path);
if (!initialized_) {
*error_msg = dlerror();
return false;