Commit ac213e3d by Nicolas Capens

Try resolving existing X11 symbols before loading libX11.

libX11 may have already been loaded (dynamically or statically) by the application. Attempting to load it again could result in a different version being loaded, causing various compatibility issues. Bug b/32880157 Change-Id: Ica8e6b1c85b82469885a20dcef31e25e6b598132 Reviewed-on: https://swiftshader-review.googlesource.com/8348Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 9d52e7fe
...@@ -56,21 +56,24 @@ LibX11exports *LibX11::loadExports() ...@@ -56,21 +56,24 @@ LibX11exports *LibX11::loadExports()
if(!libX11) if(!libX11)
{ {
libX11 = loadLibrary("libX11.so"); if(getProcAddress(RTLD_DEFAULT, "XOpenDisplay")) // Search the global scope for pre-loaded X11 library.
if(libX11)
{ {
libXext = loadLibrary("libXext.so"); libX11exports = new LibX11exports(RTLD_DEFAULT, RTLD_DEFAULT);
libX11exports = new LibX11exports(libX11, libXext); libX11 = (void*)-1; // No need to load it.
} }
else // Might have failed to load due to sandboxing. Search the global scope for pre-loaded library. else
{ {
if(getProcAddress(RTLD_DEFAULT, "XOpenDisplay")) libX11 = loadLibrary("libX11.so");
if(libX11)
{ {
libX11exports = new LibX11exports(RTLD_DEFAULT, RTLD_DEFAULT); libXext = loadLibrary("libXext.so");
libX11exports = new LibX11exports(libX11, libXext);
}
else
{
libX11 = (void*)-1; // Don't attempt loading more than once.
} }
libX11 = (void*)-1; // Don't attempt loading more than once.
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment