From: Carl Worth Date: Wed, 12 Jun 2013 23:22:06 +0000 (-0700) Subject: Fix to actually load the real libGL.so when the application asks for it. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=ad0f6ba12d81e4704ce2ba59795d9e1dd31098d7;hp=54157251d30d586e8f97fb594f22bf18e9ac4bbe;p=fips Fix to actually load the real libGL.so when the application asks for it. Our wrapper library intercepts calls to dlopen "libGL.so" and returns a handle to itself. That's correct, and as intended. Before doing this, however, it's essential to actual dlopen "libGL.so" for real even though we won't be returning a handle to it. This ensures that any side effects from that dlopen are taken care of. This fixes a bug where "fips apitrace replay foo.trace" would cause Mesa to fail to load its driver as follows (with LIBGL_DEBUG=verbose): libGL: OpenDriver: trying .../lib/dri/i965_dri.so libGL error: dlopen .../lib/dri/i965_dri.so failed (.../lib/libdricore9.2.0.so.1: undefined symbol: _glapi_tls_Context) --- diff --git a/dlwrap.c b/dlwrap.c index 9f623da..69ffbd1 100644 --- a/dlwrap.c +++ b/dlwrap.c @@ -41,10 +41,18 @@ void * dlopen (const char *filename, int flag) { Dl_info info; + void *ret; + + /* Before deciding whether to redirect this dlopen to our own + * library, we call the real dlopen. This assures that any + * expected side-effects from loading the intended library are + * resolved. Below, we may still return a handle pointing to + * our own library, and not what is opened here. */ + ret = dlwrap_real_dlopen (filename, flag); /* Not libGL, so just return real dlopen */ if (STRNCMP_LITERAL (filename, "libGL.so")) - return dlwrap_real_dlopen (filename, flag); + return ret; /* Otherwise, for all libGL lookups we redirectl dlopens to * our own library. If we've resolved libfips_handle before,