Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41132610 authored by Jesse Hall's avatar Jesse Hall Committed by android-build-merger
Browse files

libvulkan: Load layer libraries into the app namespace

am: 40c07a1d

* commit '40c07a1d':
  libvulkan: Load layer libraries into the app namespace

Change-Id: If91efcb98b45650931bd6a01879378a4e73fcc11
parents 2388035f 40c07a1d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -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();
    };
    };
}
}
+17 −0
Original line number Original line Diff line number Diff line
@@ -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>
@@ -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(),
+1 −1
Original line number Original line Diff line number Diff line
@@ -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;
}
}