- /* Otherwise, for all libGL lookups we redirectl dlopens to
- * our own library. If we've resolved libfips_handle before,
- * our work is done. */
+ /* When the application dlopens any wrapped library starting
+ * with 'libGL', (whether libGL.so.1 or libGLESv2.so.2), let's
+ * continue to use that library handle for future lookups of
+ * OpenGL functions. */
+ if (STRNCMP_LITERAL (filename, "libGL") == 0)
+ glwrap_set_gl_handle (ret);
+
+ assert (index < ARRAY_SIZE(orig_handles));
+ orig_handles[index] = ret;
+
+ /* Otherwise, we return our own handle so that we can intercept
+ * future calls to dlsym. We encode the index in the return value
+ * so that we can later map back to the originally requested
+ * dlopen-handle if necessary. */