--- a/dl.c Thu Dec 23 00:46:07 2010 +0100
+++ b/dl.c Thu Dec 23 01:06:04 2010 +0100
@@ -3,18 +3,22 @@
#include <stdlib.h>
#include "dl.h"
-void *get_original_function(const char *soname, const char *name)
+#define DEFAULT_LIB "libc.so.6"
+
+void *lib_function(const char *name, const char *soname)
{
+ void *rc;
const char* error;
- void *handle = dlopen(soname, RTLD_LAZY);
- void *rc;
+ void *handle;
+
- if (!handle) {
+
+ if (!(handle = dlopen(soname ? soname : DEFAULT_LIB, RTLD_LAZY))) {
fprintf(stderr, "dlopen on %s: %s\n", soname, dlerror());
exit(1);
}
- dlerror();
+ dlerror(); /* clear the error flag */
rc = dlsym(handle, name);
if ((error = dlerror())) {
fprintf(stderr, "dlsym for %s: %s\n", name, error);