[PATCH] loader: Use RTLD_DEEPBIND if available to prefer local symbols

Michel Dänzer michel at daenzer.net
Wed Aug 14 01:51:27 PDT 2013


On Mon, 2013-08-12 at 18:25 +0200, Egbert Eich wrote:
> If there are namespace clashes among different drivers it would be
> preferrable if each driver used its local symbols. Use the
> RTLD_DEEPBIND if available to achive this.

Makes sense to me, FWIW.

Should this be extended to the other dlopen() calls as well, in
particular in glx/glxdricommon.c? I wonder if that might help for
https://bugs.freedesktop.org/show_bug.cgi?id=68085 e.g.


> diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
> index 64c69bb..f7bae3c 100644
> --- a/hw/xfree86/loader/loader.c
> +++ b/hw/xfree86/loader/loader.c
> @@ -128,8 +128,12 @@ LoaderOpen(const char *module, int *errmaj, int *errmin)
>  #endif
>  
>      xf86Msg(X_INFO, "Loading %s\n", module);
> -
> -    if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
> +#if defined(DLOPEN_HAVE_DEEPBIND)
> +    if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL | RTLD_DEEPBIND)))
> +#else
> +    if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL)))
> +#endif
> +    {
>          xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
>          if (errmaj)
>              *errmaj = LDR_NOLOAD;
> @@ -152,8 +156,11 @@ LoaderSymbol(const char *name)
>          return p;
>  
>      if (!global_scope)
> +#if defined(DLOPEN_HAVE_DEEPBIND)
> +        global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL | RTLD_DEEPBIND);
> +#else
>          global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
> -
> +#endif
>      if (global_scope)
>          return dlsym(global_scope, name);

You could make this cleaner via DLOPEN_DEEPBIND, defined to
RTLD_DEEPBIND or 0.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer



More information about the xorg-devel mailing list