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

Commit b732030e authored by Justin Yun's avatar Justin Yun
Browse files

EGL: Do not look up default namespace when sphal is defined

If sphal name space exists, try to load drivers from sphal.
This patch stops loading the driver if it fails to find the driver
from sphal, instead of falling back to the default namespace.

Bug: 38435840
Test: sailfish builds and boots
Change-Id: Ib8ba73f57aa25431c4a2efe7c61a3699237cc3d2
parent 9b8c084f
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ cc_library_shared {
        "EGL/Loader.cpp",
        "EGL/Loader.cpp",
        "EGL/BlobCache.cpp",
        "EGL/BlobCache.cpp",
    ],
    ],
    shared_libs: ["libvndksupport"],
    static_libs: ["libEGL_getProcAddress"],
    static_libs: ["libEGL_getProcAddress"],
    ldflags: ["-Wl,--exclude-libs=ALL"],
    ldflags: ["-Wl,--exclude-libs=ALL"],
    export_include_dirs: ["EGL/include"],
    export_include_dirs: ["EGL/include"],
+9 −19
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <log/log.h>
#include <log/log.h>


#include <graphicsenv/GraphicsEnv.h>
#include <graphicsenv/GraphicsEnv.h>
#include <vndksupport/linker.h>


#include "egl_trace.h"
#include "egl_trace.h"
#include "egldefs.h"
#include "egldefs.h"
@@ -115,6 +116,11 @@ static void* do_android_dlopen_ext(const char* path, int mode, const android_dle
    return android_dlopen_ext(path, mode, info);
    return android_dlopen_ext(path, mode, info);
}
}


static void* do_android_load_sphal_library(const char* path, int mode) {
    ATRACE_CALL();
    return android_load_sphal_library(path, mode);
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


Loader::driver_t::driver_t(void* gles)
Loader::driver_t::driver_t(void* gles)
@@ -424,27 +430,11 @@ static void* load_system_driver(const char* kind) {
    const char* const driver_absolute_path = absolutePath.c_str();
    const char* const driver_absolute_path = absolutePath.c_str();


    // Try to load drivers from the 'sphal' namespace, if it exist. Fall back to
    // Try to load drivers from the 'sphal' namespace, if it exist. Fall back to
    // the original routine when the namespace does not exist or the load from
    // the original routine when the namespace does not exist.
    // the namespace fails.
    // See /system/core/rootdir/etc/ld.config.txt for the configuration of the
    // See /system/core/rootdir/etc/ld.config.txt for the configuration of the
    // sphal namespace.
    // sphal namespace.
    android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
    void* dso = do_android_load_sphal_library(driver_absolute_path,
    if (sphal_namespace != NULL) {
                                              RTLD_NOW | RTLD_LOCAL);
        const android_dlextinfo dlextinfo = {
            .flags = ANDROID_DLEXT_USE_NAMESPACE,
            .library_namespace = sphal_namespace,
        };
        void* dso = do_android_dlopen_ext(driver_absolute_path, RTLD_LOCAL | RTLD_NOW, &dlextinfo);
        if (dso) {
            ALOGD("loaded %s from sphal namespace", driver_absolute_path);
            return dso;
        }
        else {
            ALOGW("failed to load %s from sphal namespace: %s", driver_absolute_path, dlerror());
        }
    }

    void* dso = do_dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
    if (dso == 0) {
    if (dso == 0) {
        const char* err = dlerror();
        const char* err = dlerror();
        ALOGE("load_driver(%s): %s", driver_absolute_path, err ? err : "unknown");
        ALOGE("load_driver(%s): %s", driver_absolute_path, err ? err : "unknown");