Skip to content

Commit

Permalink
dispatch: dlopen libGL.so with RTLD_DEEPBIND.
Browse files Browse the repository at this point in the history
According to the dlopen() docs, a deep bind will resolve unresolved
symbols inside the dlopen()-ed library, within the library itself first.
This way the symbols in the Mesa's GLX_functions array will get resolved
inside Mesa, and not with apitrace symbols.
  • Loading branch information
gkyriazis authored and jrfonseca committed Jun 1, 2017
1 parent cbb48c5 commit 63194b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dispatch/glproc_egl.cpp
Expand Up @@ -89,7 +89,7 @@ _getPublicProcAddress(const char *procName)
if (procName[0] == 'e' && procName[1] == 'g' && procName[2] == 'l') {
static void *libEGL = NULL;
if (!libEGL) {
libEGL = _dlopen("libEGL.so", RTLD_LOCAL | RTLD_LAZY);
libEGL = _dlopen("libEGL.so", RTLD_LOCAL | RTLD_LAZY | RTLD_DEEPBIND);
if (!libEGL) {
return NULL;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ _getPublicProcAddress(const char *procName)

static void *libGLESv2 = NULL;
if (!libGLESv2) {
libGLESv2 = _dlopen("libGLESv2.so", RTLD_LOCAL | RTLD_LAZY);
libGLESv2 = _dlopen("libGLESv2.so", RTLD_LOCAL | RTLD_LAZY | RTLD_DEEPBIND);
}
if (libGLESv2) {
proc = dlsym(libGLESv2, procName);
Expand All @@ -143,7 +143,7 @@ _getPublicProcAddress(const char *procName)

static void *libGLESv1 = NULL;
if (!libGLESv1) {
libGLESv1 = _dlopen("libGLESv1_CM.so", RTLD_LOCAL | RTLD_LAZY);
libGLESv1 = _dlopen("libGLESv1_CM.so", RTLD_LOCAL | RTLD_LAZY | RTLD_DEEPBIND);
}
if (libGLESv1) {
proc = dlsym(libGLESv1, procName);
Expand Down
2 changes: 1 addition & 1 deletion dispatch/glproc_gl.cpp
Expand Up @@ -200,7 +200,7 @@ void * _libgl_sym(const char *symbol)
* exposes symbols to it.
*/

_libGlHandle = _dlopen(libgl_filename, RTLD_GLOBAL | RTLD_LAZY);
_libGlHandle = _dlopen(libgl_filename, RTLD_GLOBAL | RTLD_LAZY | RTLD_DEEPBIND);
if (!_libGlHandle) {
os::log("apitrace: error: couldn't find libGL.so\n");
return NULL;
Expand Down

0 comments on commit 63194b2

Please sign in to comment.