Last active
September 11, 2020 22:19
-
-
Save weskerfoot/77e880279bb9aad93ac65125f4322c8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <stdio.h> | |
typedef void* (*real_dlopen_t)(const char*, int); | |
void* | |
real_dlopen(const char *filename, int flags) { | |
return ((real_dlopen_t)dlsym(RTLD_NEXT, "dlopen"))(filename, flags); | |
} | |
void* | |
dlopen(const char *filename, int flags) { | |
printf("Loading library %s\n", filename); | |
void *result = real_dlopen(filename, RTLD_NOW); | |
char *error = dlerror(); | |
if (error != NULL) { | |
printf(error); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
compile with
gcc -shared -fPIC -o logdlopen.so logdlopen.c
and doLD_PRELOAD=./logdlopen.so my_command