diff -r 000000000000 -r 7d3c07f8acfb dl.c --- /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 +#include +#include +#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; +}