I'll note that the LD_PRELOAD interposer library is only needed for binaries that are already compiled and you want to override the pthread_mutex_lock() routine. If you can recompile your source, then you can place the interposer directly into your source and there is no need for LD_PRELOADing anything. Ie, you could just add the following to any of your source files:
#define PTHREAD_MUTEX_NO_ELISION_NP (512)
extern int __pthread_mutex_lock (pthread_mutex_t *);
int
pthread_mutex_lock (pthread_mutex_t *mutex)
{
mutex->__data.__kind |= PTHREAD_MUTEX_NO_ELISION_NP;
return __pthread_mutex_lock (mutex);
}
I'll note that the LD_PRELOAD interposer library is only needed for binaries that are already compiled and you want to override the pthread_ mutex_lock( ) routine. If you can recompile your source, then you can place the interposer directly into your source and there is no need for LD_PRELOADing anything. Ie, you could just add the following to any of your source files:
#define PTHREAD_ MUTEX_NO_ ELISION_ NP (512)
extern int __pthread_ mutex_lock (pthread_mutex_t *); >__data. __kind |= PTHREAD_ MUTEX_NO_ ELISION_ NP; mutex_lock (mutex);
int
pthread_mutex_lock (pthread_mutex_t *mutex)
{
mutex-
return __pthread_
}