You can find the symbol of the original pthread_create function by calling:
pthread_create_orig = dlsym(RTLD_NEXT, "pthread_create");
Then the wrapper will look like this:
#include <dlfcn.h>
int (*pthread_create_orig)(pthread_t *, const pthread_attr_t *, void *(*) (void *), void *);
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start) (void *), void *arg) {
if (!pthread_create_orig)
pthread_create_orig = dlsym(RTLD_NEXT, "pthread_create");
return pthread_create_orig(thread, attr, start, arg);
}
.
: dlsym() , dlopen(). RTLD_NEXT , .. , . libpthread, , .