[Mesa-dev] [PATCH] radeon/llvm: Use LLVM C API for compiling LLVM IR to ISA.

Tom Stellard tom at stellard.net
Wed Apr 24 14:15:06 PDT 2013


On Wed, Apr 24, 2013 at 09:40:44PM +0200, Mathias Fröhlich wrote:
> 
> Hi Tom,
> 
> On Tuesday, April 23, 2013 20:47:24 Tom Stellard wrote:
> > First of all, thanks for investigating this.  The information you've
> > provided has helped me a lot.
> Good to hear that it helps.
> 
> > I took a shot at implementing it this way with private static copies of
> > llvm.  I've pushed the initial work to this branch:
> > git://people.freedesktop.org/~tstellar/mesa llvm-build
> > 
> > I was able to hide the LLVM symbols by using the --exclude-libs linker
> > flag and so far I've tested with glxgears, an opencl example and also
> > eglgears and they all work.  I still need to do some more testing, but
> > any thoughts on what I've done so far in this branch?
> 
> I will look at this as soon as I find time. Probably not before the beginning 
> of next week.
> 

I've thought about this some more, and I think that the best solution
might be to move all LLVM API calls into gallivm and build it as a
shared object with it's own private copy of LLVM statically linked.  This way we
would still have a private copy of LLVM to work with, but without having
to statically link every single gallium target with LLVM.  Any thoughts
about this?

> For now, I have attached the patch series I mentioned regarding dlopen flags 
> which could be an other approach for this. I don't mind which approach you 
> really take in the end. Anyway this appears to work up to now. It would have 
> the advantage that it also helps other drivers beside r600g with the llvm 
> issues and it would help much further for all the non static private symbols 
> we have in the drivers. The series is running here in my private tree since 
> about half a year.
> 

A few questions about the RTL_DEEPBIND patches:

1. Does this only work for linux?

2. Does RTL_DEEPBIND only make a difference if we are statically linking to
LLVM?


> I have also done a testcase in piglit that shows the current problem with 
> r600g and llvm. To be really general we should put an other symbol there 
> instead of the llvm context initializer. But as a first test case you can work 
> with, this should be sufficient. That one really fails with current r600g/llvm 
> and works with the dlopen patch series. Consequently if you want to make sure 
> your branch works on a private llvm version, this test needs to pass also.
> 

This testcase is great, thanks.

-Tom

> Feel free to take and improove the provided patches.
> 
> Greetings
> 
> Mathias

> From 757a111221774703d558b5807e7465a026d6a3f8 Mon Sep 17 00:00:00 2001
> Message-Id: <757a111221774703d558b5807e7465a026d6a3f8.1366832004.git.Mathias.Froehlich at gmx.net>
> From: Mathias Froehlich <Mathias.Froehlich at web.de>
> Date: Wed, 24 Apr 2013 09:35:17 +0200
> Subject: [PATCH] Add test for driver private symbol isolation.
> 
> ---
>  tests/general/CMakeLists.gl.txt          |  5 ++++
>  tests/general/driver-isolation-library.c | 36 ++++++++++++++++++++++
>  tests/general/driver-isolation.c         | 51 ++++++++++++++++++++++++++++++++
>  3 files changed, 92 insertions(+)
>  create mode 100644 tests/general/driver-isolation-library.c
>  create mode 100644 tests/general/driver-isolation.c
> 
> diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
> index 0e87baa..6beb745 100644
> --- a/tests/general/CMakeLists.gl.txt
> +++ b/tests/general/CMakeLists.gl.txt
> @@ -81,6 +81,11 @@ piglit_add_executable (line-aa-width line-aa-width.c)
>  IF (UNIX)
>  	target_link_libraries (line-aa-width m)
>  ENDIF (UNIX)
> +IF (UNIX)
> +	add_library (driver-isolation-library SHARED driver-isolation-library.c)
> +	piglit_add_executable (driver-isolation driver-isolation.c)
> +	target_link_libraries (driver-isolation driver-isolation-library)
> +ENDIF (UNIX)
>  piglit_add_executable (longprim longprim.c)
>  piglit_add_executable (masked-clear masked-clear.c)
>  piglit_add_executable (pos-array pos-array.c)
> diff --git a/tests/general/driver-isolation-library.c b/tests/general/driver-isolation-library.c
> new file mode 100644
> index 0000000..ef307a3
> --- /dev/null
> +++ b/tests/general/driver-isolation-library.c
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (c) 2013 Mathias Fröhlich.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, and/or sell copies of the Software, and to permit persons to whom
> + * the Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NON-INFRINGEMENT.  IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +void
> +my_important_function()
> +{
> +}
> +
> +void*
> +LLVMContextCreate()
> +{
> +	/* If we really get here, symbol isolation does not work.
> +	 */
> +	exit(-1);
> +}
> diff --git a/tests/general/driver-isolation.c b/tests/general/driver-isolation.c
> new file mode 100644
> index 0000000..ee81202
> --- /dev/null
> +++ b/tests/general/driver-isolation.c
> @@ -0,0 +1,51 @@
> +/*
> + * Copyright (c) 2013 Mathias Fröhlich.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, and/or sell copies of the Software, and to permit persons to whom
> + * the Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NON-INFRINGEMENT.  IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +/* Test that the drivers internal symbols cannot conflict with any
> + * application provided symbol of the same name.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 10;
> +
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +extern void my_important_function();
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	return PIGLIT_PASS;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	my_important_function();
> +}
> -- 
> 1.8.1.4
> 

> From c43a2ae15fe3adaa764175d076d07895351834f6 Mon Sep 17 00:00:00 2001
> Message-Id: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 1/8] glx/dri: Use RTLD_LOCAL | RTLD_DEEPBIND instead of
>  RTLD_GLOBAL.
> 
> To avoid symbol collisions due to the increasing use of shared
> linking, which in turn requires some more symbols to be visible,
> load drivers without pushing their symbols into the global
> namespace.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/glx/dri_common.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
> index 1bf20ec..d762b43 100644
> --- a/src/glx/dri_common.c
> +++ b/src/glx/dri_common.c
> @@ -47,6 +47,9 @@
>  #ifndef RTLD_GLOBAL
>  #define RTLD_GLOBAL 0
>  #endif
> +#ifndef RTLD_DEEPBIND
> +#define RTLD_DEEPBIND 0
> +#endif
>  
>  /**
>   * Print informational message to stderr if LIBGL_DEBUG is set to
> @@ -162,14 +165,18 @@ driOpenDriver(const char *driverName)
>        snprintf(realDriverName, sizeof realDriverName,
>                 "%.*s/tls/%s_dri.so", len, p, driverName);
>        InfoMessageF("OpenDriver: trying %s\n", realDriverName);
> -      handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
> +      /* The driver and everything in there should be invisible to
> +         anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +      handle = dlopen(realDriverName, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>  #endif
>  
>        if (handle == NULL) {
>           snprintf(realDriverName, sizeof realDriverName,
>                    "%.*s/%s_dri.so", len, p, driverName);
>           InfoMessageF("OpenDriver: trying %s\n", realDriverName);
> -         handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
> +         /* The driver and everything in there should be invisible to
> +            anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +         handle = dlopen(realDriverName, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>        }
>  
>        if (handle != NULL)
> -- 
> 1.8.1.4
> 

> From 1708d90af8665d93d6d07b5d200e5a54cfd1ab2b Mon Sep 17 00:00:00 2001
> Message-Id: <1708d90af8665d93d6d07b5d200e5a54cfd1ab2b.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 2/8] egl/dri2: Use RTLD_LOCAL | RTLD_DEEPBIND instead of
>  RTLD_GLOBAL.
> 
> To avoid symbol collisions due to the increasing use of shared
> linking, which in turn requires some more symbols to be visible,
> load drivers without pushing their symbols into the global
> namespace.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 1011f27..bfa71df 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -41,6 +41,10 @@
>  
>  #include "egl_dri2.h"
>  
> +#ifndef RTLD_DEEPBIND
> +#define RTLD_DEEPBIND 0
> +#endif
> +
>  const __DRIuseInvalidateExtension use_invalidate = {
>     { __DRI_USE_INVALIDATE, 1 }
>  };
> @@ -395,12 +399,16 @@ dri2_open_driver(_EGLDisplay *disp)
>  #if GLX_USE_TLS
>        snprintf(path, sizeof path,
>  	       "%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name);
> -      dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
> +      /* The driver and everything in there should be invisible to
> +         anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +      dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>  #endif
>        if (dri2_dpy->driver == NULL) {
>  	 snprintf(path, sizeof path,
>  		  "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name);
> -	 dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
> +         /* The driver and everything in there should be invisible to
> +            anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +	 dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>  	 if (dri2_dpy->driver == NULL)
>  	    _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
>        }
> -- 
> 1.8.1.4
> 

> From cc9ac8368de9ec95574fed44d807eb5004fe8e09 Mon Sep 17 00:00:00 2001
> Message-Id: <cc9ac8368de9ec95574fed44d807eb5004fe8e09.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 3/8] egl/driver: Use RTLD_DEEPBIND if available.
> 
> Increase the symbol isolation level for the chain loaded
> driver module.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/egl/main/egldriver.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
> index ffdd146..396e6a4 100644
> --- a/src/egl/main/egldriver.c
> +++ b/src/egl/main/egldriver.c
> @@ -50,6 +50,11 @@
>  #include <sys/types.h>
>  #include <dirent.h>
>  #include <unistd.h>
> +
> +#ifndef RTLD_DEEPBIND
> +#define RTLD_DEEPBIND 0
> +#endif
> +
>  #endif
>  
>  
> @@ -115,7 +120,7 @@ typedef void * lib_handle;
>  static void *
>  open_library(const char *filename)
>  {
> -   return dlopen(filename, RTLD_LAZY);
> +   return dlopen(filename, RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
>  }
>  
>  static void
> -- 
> 1.8.1.4
> 

> From 147ac5087664cd7a08b1c96edb2801e831f163bb Mon Sep 17 00:00:00 2001
> Message-Id: <147ac5087664cd7a08b1c96edb2801e831f163bb.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 4/8] gbm/dri: Use RTLD_LOCAL | RTLD_DEEPBIND instead of
>  RTLD_GLOBAL.
> 
> To avoid symbol collisions due to the increasing use of shared
> linking, which in turn requires some more symbols to be visible,
> load drivers without pushing their symbols into the global
> namespace.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/gbm/backends/dri/gbm_dri.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
> index a3a0530..b1d15cb 100644
> --- a/src/gbm/backends/dri/gbm_dri.c
> +++ b/src/gbm/backends/dri/gbm_dri.c
> @@ -41,6 +41,10 @@
>  #include <GL/gl.h> /* dri_interface needs GL types */
>  #include <GL/internal/dri_interface.h>
>  
> +#ifndef RTLD_DEEPBIND
> +#define RTLD_DEEPBIND 0
> +#endif
> +
>  #include "gbm_driint.h"
>  
>  #include "gbmint.h"
> @@ -192,12 +196,16 @@ dri_load_driver(struct gbm_dri_device *dri)
>  #if GLX_USE_TLS
>        snprintf(path, sizeof path,
>                 "%.*s/tls/%s_dri.so", len, p, dri->base.driver_name);
> -      dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
> +      /* The driver and everything in there should be invisible to
> +         anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +      dri->driver = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>  #endif
>        if (dri->driver == NULL) {
>           snprintf(path, sizeof path,
>                    "%.*s/%s_dri.so", len, p, dri->base.driver_name);
> -         dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
> +         /* The driver and everything in there should be invisible to
> +            anybody else. Therefore the RTLD_LOCAL | RTLD_DEEPBIND */
> +         dri->driver = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
>           if (dri->driver == NULL)
>              fprintf(stderr, "failed to open %s: %s\n", path, dlerror());
>        }
> -- 
> 1.8.1.4
> 

> From 42f6a2ea7499f169d39c1e65b9a32dd3e81a45a9 Mon Sep 17 00:00:00 2001
> Message-Id: <42f6a2ea7499f169d39c1e65b9a32dd3e81a45a9.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 6/8] mesa: Remove unused RTLD_* defines.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/mesa/main/texcompress_s3tc.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
> index 02f2c7c..9f8d00b 100644
> --- a/src/mesa/main/texcompress_s3tc.c
> +++ b/src/mesa/main/texcompress_s3tc.c
> @@ -49,8 +49,6 @@
>  
>  #if defined(_WIN32) || defined(WIN32)
>  #define DXTN_LIBNAME "dxtn.dll"
> -#define RTLD_LAZY 0
> -#define RTLD_GLOBAL 0
>  #elif defined(__DJGPP__)
>  #define DXTN_LIBNAME "dxtn.dxe"
>  #else
> -- 
> 1.8.1.4
> 

> From 83cfba631c655cca24fec72d8c0b8e672ca79cc0 Mon Sep 17 00:00:00 2001
> Message-Id: <83cfba631c655cca24fec72d8c0b8e672ca79cc0.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:27 +0100
> Subject: [PATCH 5/8] mesa: Use RTLD_LOCAL | RTLD_DEEPBIND instead of
>  RTLD_GLOBAL.
> 
> To avoid symbol collisions due to the increasing use of shared
> linking, which in turn requires some more symbols to be visible,
> load drivers without pushing their symbols into the global
> namespace.
> The only user of this mesa function as of today is loading
> the compression library shared object, which should be loaded
> with private symbols anyway.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/mesa/main/dlopen.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/main/dlopen.h b/src/mesa/main/dlopen.h
> index 55a56f0..5646622 100644
> --- a/src/mesa/main/dlopen.h
> +++ b/src/mesa/main/dlopen.h
> @@ -50,7 +50,10 @@ _mesa_dlopen(const char *libname, int flags)
>  #if defined(__blrts)
>     return NULL;
>  #elif defined(HAVE_DLOPEN)
> -   flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
> +   flags = RTLD_LAZY | RTLD_LOCAL; /* Overriding flags at this time */
> +#ifdef RTLD_DEEPBIND
> +   flags |= RTLD_DEEPBIND;
> +#endif
>     return dlopen(libname, flags);
>  #elif defined(__MINGW32__)
>     return LoadLibraryA(libname);
> -- 
> 1.8.1.4
> 

> From 26c5a5a01c3fd9f765465e50df86bd8bb35f1a1a Mon Sep 17 00:00:00 2001
> Message-Id: <26c5a5a01c3fd9f765465e50df86bd8bb35f1a1a.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:28 +0100
> Subject: [PATCH 7/8] egl/glx: Use RTLD_DEEPBIND if available.
> 
> Increase the symbol isolation level for the chain loaded
> libGL.so that provides the backend for egl.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/egl/drivers/glx/egl_glx.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
> index 8fe19f9..a74b1ac 100644
> --- a/src/egl/drivers/glx/egl_glx.c
> +++ b/src/egl/drivers/glx/egl_glx.c
> @@ -50,6 +50,10 @@
>  #include "egllog.h"
>  #include "eglsurface.h"
>  
> +#ifndef RTLD_DEEPBIND
> +#define RTLD_DEEPBIND 0
> +#endif
> +
>  #define CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))
>  
>  #ifndef GLX_VERSION_1_4
> @@ -1074,7 +1078,7 @@ GLX_Load(_EGLDriver *drv)
>     if (!GLX_drv->glXGetProcAddress)
>        GLX_drv->glXGetProcAddress = dlsym(RTLD_DEFAULT, "glXGetProcAddressARB");
>     if (!GLX_drv->glXGetProcAddress) {
> -      handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
> +      handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
>        if (!handle)
>           goto fail;
>  
> -- 
> 1.8.1.4
> 

> From e4dac328fa9effa058e27e0fd5e2b399ac7f0d92 Mon Sep 17 00:00:00 2001
> Message-Id: <e4dac328fa9effa058e27e0fd5e2b399ac7f0d92.1366832037.git.Mathias.Froehlich at gmx.net>
> In-Reply-To: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> References: <c43a2ae15fe3adaa764175d076d07895351834f6.1366832037.git.Mathias.Froehlich at gmx.net>
> From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <Mathias.Froehlich at gmx.net>
> Date: Sun, 20 Jan 2013 09:45:28 +0100
> Subject: [PATCH 8/8] egl/glx: Load libGL.so.1 to get glx entry points.
> 
> Probe for libGL.so.1 instead of libGL.so since the later
> is typically only installed with the development libraries
> and the former comes with the runtime packages.
> 
> Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
> ---
>  src/egl/drivers/glx/egl_glx.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
> index a74b1ac..6decc39 100644
> --- a/src/egl/drivers/glx/egl_glx.c
> +++ b/src/egl/drivers/glx/egl_glx.c
> @@ -1078,7 +1078,9 @@ GLX_Load(_EGLDriver *drv)
>     if (!GLX_drv->glXGetProcAddress)
>        GLX_drv->glXGetProcAddress = dlsym(RTLD_DEFAULT, "glXGetProcAddressARB");
>     if (!GLX_drv->glXGetProcAddress) {
> -      handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
> +      handle = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
> +      if (!handle)
> +         handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
>        if (!handle)
>           goto fail;
>  
> -- 
> 1.8.1.4
> 



More information about the mesa-dev mailing list