--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dl.c Thu Dec 23 00:46:07 2010 +0100
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "dl.h"
+
+void *get_original_function(const char *soname, const char *name)
+{
+ const char* error;
+ void *handle = dlopen(soname, RTLD_LAZY);
+ void *rc;
+
+ if (!handle) {
+ fprintf(stderr, "dlopen on %s: %s\n", soname, dlerror());
+ exit(1);
+ }
+
+ dlerror();
+ rc = dlsym(handle, name);
+ if ((error = dlerror())) {
+ fprintf(stderr, "dlsym for %s: %s\n", name, error);
+ exit(1);
+ }
+ dlclose(handle);
+
+ return rc;
+}