From 0e72547039e7633712fada41ef744c60aa7e7ebb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 May 2014 23:24:13 +0100 Subject: glxtrace: Use dlsym protection only on wrappers. Similar in spirit to the Lawrence Love's pull request #203, but instead of building multiple variants of glproc_gl.cpp simply move the dlsym protection code into wrappers dir. --- dispatch/glproc_gl.cpp | 54 +------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'dispatch') diff --git a/dispatch/glproc_gl.cpp b/dispatch/glproc_gl.cpp index 0ced2f95..fdbea05c 100644 --- a/dispatch/glproc_gl.cpp +++ b/dispatch/glproc_gl.cpp @@ -160,58 +160,6 @@ logSymbol(const char *name, void *ptr) { } -#ifdef __GLIBC__ -extern "C" void * __libc_dlsym(void *, const char *); -#endif - - -/* - * Protect against dlsym interception. - * - * We implement the whole API, so we don't need to intercept dlsym -- dlopen is - * enough. However we need to protect against other dynamic libraries - * intercepting dlsym, to prevent infinite recursion, - * - * In particular the Steam Community Overlay advertises dlsym. See also - * http://lists.freedesktop.org/archives/apitrace/2013-March/000573.html - */ -static inline void * -_dlsym(void *handle, const char *symbol) -{ - void *result; - -#ifdef __GLIBC__ - /* - * We rely on glibc's internal __libc_dlsym. See also - * http://www.linuxforu.com/2011/08/lets-hook-a-library-function/ - * - * Use use it to obtain the true dlsym. We don't use __libc_dlsym directly - * because it does not support things such as RTLD_NEXT. - */ - typedef void * (*PFN_DLSYM)(void *, const char *); - static PFN_DLSYM dlsym_ptr = NULL; - if (!dlsym_ptr) { - void *libdl_handle = _dlopen("libdl.so.2", RTLD_LOCAL | RTLD_NOW); - if (libdl_handle) { - dlsym_ptr = (PFN_DLSYM)__libc_dlsym(libdl_handle, "dlsym"); - } - if (!dlsym_ptr) { - os::log("apitrace: error: failed to look up real dlsym\n"); - return NULL; - } - - logSymbol("dlsym", (void*)dlsym_ptr); - } - - result = dlsym_ptr(handle, symbol); -#else - result = dlsym(handle, symbol); -#endif - - return result; -} - - /* * Lookup a libGL symbol */ @@ -255,7 +203,7 @@ void * _libgl_sym(const char *symbol) } } - result = _dlsym(_libGlHandle, symbol); + result = dlsym(_libGlHandle, symbol); logSymbol(symbol, result); -- cgit v1.2.3