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
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp
index bff80cd..4e275db 100644
--- a/opengl/libs/Android.bp
+++ b/opengl/libs/Android.bp
@@ -111,6 +111,7 @@
"EGL/Loader.cpp",
"EGL/BlobCache.cpp",
],
+ shared_libs: ["libvndksupport"],
static_libs: ["libEGL_getProcAddress"],
ldflags: ["-Wl,--exclude-libs=ALL"],
export_include_dirs: ["EGL/include"],
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 1116400..6e5c510 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -29,6 +29,7 @@
#include <log/log.h>
#include <graphicsenv/GraphicsEnv.h>
+#include <vndksupport/linker.h>
#include "egl_trace.h"
#include "egldefs.h"
@@ -115,6 +116,11 @@
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)
@@ -424,27 +430,11 @@
const char* const driver_absolute_path = absolutePath.c_str();
// 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 namespace fails.
+ // the original routine when the namespace does not exist.
// See /system/core/rootdir/etc/ld.config.txt for the configuration of the
// sphal namespace.
- android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
- if (sphal_namespace != NULL) {
- 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);
+ void* dso = do_android_load_sphal_library(driver_absolute_path,
+ RTLD_NOW | RTLD_LOCAL);
if (dso == 0) {
const char* err = dlerror();
ALOGE("load_driver(%s): %s", driver_absolute_path, err ? err : "unknown");