Loading vulkan/include/vulkan/vulkan_loader_data.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -19,9 +19,13 @@ #include <string> #include <string> struct android_namespace_t; namespace vulkan { namespace vulkan { struct LoaderData { struct LoaderData { std::string layer_path; std::string layer_path; android_namespace_t* app_namespace; __attribute__((visibility("default"))) static LoaderData& GetInstance(); __attribute__((visibility("default"))) static LoaderData& GetInstance(); }; }; } } Loading vulkan/libvulkan/layers_extensions.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <vector> #include <vector> #include <android-base/strings.h> #include <android-base/strings.h> #include <android/dlext.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <log/log.h> #include <log/log.h> #include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h> Loading Loading @@ -104,6 +105,22 @@ bool LayerLibrary::Open() { std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_); if (refcount_++ == 0) { if (refcount_++ == 0) { ALOGV("opening layer library '%s'", path_.c_str()); ALOGV("opening layer library '%s'", path_.c_str()); // Libraries in the system layer library dir can't be loaded into // the application namespace. That causes compatibility problems, since // any symbol dependencies will be resolved by system libraries. They // can't safely use libc++_shared, for example. Which is one reason // (among several) we only allow them in non-user builds. auto app_namespace = LoaderData::GetInstance().app_namespace; if (app_namespace && !android::base::StartsWith(path_, kSystemLayerLibraryDir)) { android_dlextinfo dlextinfo = {}; dlextinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; dlextinfo.library_namespace = app_namespace; dlhandle_ = android_dlopen_ext(path_.c_str(), RTLD_NOW | RTLD_LOCAL, &dlextinfo); } else { dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); } dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); if (!dlhandle_) { if (!dlhandle_) { ALOGE("failed to load layer library '%s': %s", path_.c_str(), ALOGE("failed to load layer library '%s': %s", path_.c_str(), Loading vulkan/libvulkan/vulkan_loader_data.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,6 @@ using namespace vulkan; using namespace vulkan; LoaderData& LoaderData::GetInstance() { LoaderData& LoaderData::GetInstance() { static LoaderData loader_data; static LoaderData loader_data = {}; return loader_data; return loader_data; } } Loading
vulkan/include/vulkan/vulkan_loader_data.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -19,9 +19,13 @@ #include <string> #include <string> struct android_namespace_t; namespace vulkan { namespace vulkan { struct LoaderData { struct LoaderData { std::string layer_path; std::string layer_path; android_namespace_t* app_namespace; __attribute__((visibility("default"))) static LoaderData& GetInstance(); __attribute__((visibility("default"))) static LoaderData& GetInstance(); }; }; } } Loading
vulkan/libvulkan/layers_extensions.cpp +17 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <vector> #include <vector> #include <android-base/strings.h> #include <android-base/strings.h> #include <android/dlext.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <log/log.h> #include <log/log.h> #include <ziparchive/zip_archive.h> #include <ziparchive/zip_archive.h> Loading Loading @@ -104,6 +105,22 @@ bool LayerLibrary::Open() { std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_); if (refcount_++ == 0) { if (refcount_++ == 0) { ALOGV("opening layer library '%s'", path_.c_str()); ALOGV("opening layer library '%s'", path_.c_str()); // Libraries in the system layer library dir can't be loaded into // the application namespace. That causes compatibility problems, since // any symbol dependencies will be resolved by system libraries. They // can't safely use libc++_shared, for example. Which is one reason // (among several) we only allow them in non-user builds. auto app_namespace = LoaderData::GetInstance().app_namespace; if (app_namespace && !android::base::StartsWith(path_, kSystemLayerLibraryDir)) { android_dlextinfo dlextinfo = {}; dlextinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; dlextinfo.library_namespace = app_namespace; dlhandle_ = android_dlopen_ext(path_.c_str(), RTLD_NOW | RTLD_LOCAL, &dlextinfo); } else { dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); } dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); dlhandle_ = dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL); if (!dlhandle_) { if (!dlhandle_) { ALOGE("failed to load layer library '%s': %s", path_.c_str(), ALOGE("failed to load layer library '%s': %s", path_.c_str(), Loading
vulkan/libvulkan/vulkan_loader_data.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,6 @@ using namespace vulkan; using namespace vulkan; LoaderData& LoaderData::GetInstance() { LoaderData& LoaderData::GetInstance() { static LoaderData loader_data; static LoaderData loader_data = {}; return loader_data; return loader_data; } }