Use global libX11 symbols when present.
Bug 20754549
Change-Id: I029310192d638a2769bf6e2d2950717d6a4c484b
Reviewed-on: https://swiftshader-review.googlesource.com/3050
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Main/libX11.cpp b/src/Main/libX11.cpp
index 9f6a56e..4b72a7c 100644
--- a/src/Main/libX11.cpp
+++ b/src/Main/libX11.cpp
@@ -46,9 +46,18 @@
if(libX11)
{
- libXext = loadLibrary("libXext.so");
- libX11exports = new LibX11exports(libX11, libXext);
- }
+ libXext = loadLibrary("libXext.so");
+ libX11exports = new LibX11exports(libX11, libXext);
+ }
+ else // Might have failed to load due to sandboxing. Search the global scope for pre-loaded library.
+ {
+ if(getProcAddress(RTLD_DEFAULT, "XOpenDisplay"))
+ {
+ libX11exports = new LibX11exports(RTLD_DEFAULT, RTLD_DEFAULT);
+ }
+
+ libX11 = (void*)-1; // Don't attempt loading more than once.
+ }
}
return libX11exports;