The GLAZE_WRAPPER environment variable should point to a library which
has symbols for some subset of the OpenGL API. For all such symbols,
Glaze will resolve its ifunc symbols to the wrapper functions. For all
functions not having symbols in the GLAZE_WRAPPER library, Glaze will
resolve its ifunc symbols to the functions in the GLAZE_LIBGL library.
#include <stdlib.h>
void *libgl_handle;
#include <stdlib.h>
void *libgl_handle;
static void
open_libgl_handle (void)
static void
open_libgl_handle (void)
+static void
+open_wrapper_handle (void)
+{
+ const char *path;
+
+ if (wrapper_handle)
+ return;
+
+ path = getenv ("GLAZE_WRAPPER");
+ if (path == NULL) {
+ fprintf (stderr, "GLAZE_WRAPPER unset. Please set to path of real libGL.so under glaze.\n");
+ exit (1);
+ }
+
+ wrapper_handle = dlopen (path, RTLD_LAZY);
+ if (wrapper_handle == NULL) {
+ fprintf (stderr, "Error: Failed to dlopen %s\n", path);
+ exit (1);
+ }
+}
+
static void
glaze_init (void) __attribute__((constructor));
static void
glaze_init (void) __attribute__((constructor));
glaze_init (void)
{
open_libgl_handle ();
glaze_init (void)
{
open_libgl_handle ();
+ open_wrapper_handle ();
}
static void *
resolve (const char *name)
{
}
static void *
resolve (const char *name)
{
+ void *symbol;
+
+ /* The wrapper gets first choice on all symbols. */
+ symbol = dlsym (wrapper_handle, name);
+ if (symbol)
+ return symbol;
+
return dlsym (libgl_handle, name);
}
return dlsym (libgl_handle, name);
}