diff options
author | Michel Dänzer <[email protected]> | 2006-08-14 15:53:37 +0000 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2006-08-14 15:53:37 +0000 |
commit | 061a3fe34051327fba418cc99599ecff0016ee15 (patch) | |
tree | 0990885d1739c7ec1f8fc216f28b78db526fc76d /src | |
parent | 24cd8e22f5a0fda3a0811976b07755bd8cecb75c (diff) |
Bug #7169: Attempt to make libGL symbols visible to drivers.
Some applications end up dlopening libGL without RTLD_GLOBAL, so the libGL
symbols referenced by the driver can't be unresolved when libGL dlopens it.
This attempts to make the libGL symbols visible to the driver by dlopening
libGL (again) with RTLD_GLOBAL before dlopening the driver and dlclosing
the obtained handle afterwards.
Diffstat (limited to 'src')
-rw-r--r-- | src/glx/x11/dri_glx.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c index 508dceb84d8..0875361d0b6 100644 --- a/src/glx/x11/dri_glx.c +++ b/src/glx/x11/dri_glx.c @@ -183,6 +183,7 @@ static const char createNewScreenName[] = "__driCreateNewScreen_20050727"; */ static __DRIdriver *OpenDriver(const char *driverName) { + void *glhandle = NULL; char *libPaths = NULL; char libDir[1000]; int i; @@ -196,6 +197,9 @@ static __DRIdriver *OpenDriver(const char *driverName) } } + /* Attempt to make sure libGL symbols will be visible to the driver */ + glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL); + if (geteuid() == getuid()) { /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ libPaths = getenv("LIBGL_DRIVERS_PATH"); @@ -229,12 +233,13 @@ static __DRIdriver *OpenDriver(const char *driverName) /* allocate __DRIdriver struct */ driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver)); if (!driver) - return NULL; /* out of memory! */ + break; /* out of memory! */ /* init the struct */ driver->name = __glXstrdup(driverName); if (!driver->name) { Xfree(driver); - return NULL; /* out of memory! */ + driver = NULL; + break; /* out of memory! */ } driver->createNewScreenFunc = (PFNCREATENEWSCREENFUNC) @@ -248,6 +253,7 @@ static __DRIdriver *OpenDriver(const char *driverName) "Your driver may be too old for this libGL.\n", createNewScreenName, driverName); Xfree(driver); + driver = NULL; dlclose(handle); continue; } @@ -255,15 +261,20 @@ static __DRIdriver *OpenDriver(const char *driverName) /* put at head of linked list */ driver->next = Drivers; Drivers = driver; - return driver; + break; } else { ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror()); } } - ErrorMessageF("unable to find driver: %s_dri.so\n", driverName); - return NULL; + if (!driver) + ErrorMessageF("unable to load driver: %s_dri.so\n", driverName); + + if (glhandle) + dlclose(glhandle); + + return driver; } |