Code: Select all
gcc -o libsab.so -shared -ldl -D_USE_GNU test.c
test.c: Dans la fonction « malloc »:
test.c:12: error: `RTLD_NEXT' undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c: Dans la fonction « free »:
test.c:25: error: `RTLD_NEXT' undeclared (first use in this function)
test.c: Dans la fonction « glBegin »:
test.c:37: error: `RTLD_NEXT' undeclared (first use in this function)
Code: Select all
#include <stdio.h>
#include <GL/gl.h>
#include <dlfcn.h>
//#define RTLD_NEXT ((void *) -1)
void * malloc(size_t size) {
static void *(*sys_malloc)(size_t) = NULL;
if (!sys_malloc) {
if (!(sys_malloc = (void *(*)(size_t)) dlsym(RTLD_NEXT, "malloc"))) {
perror("cannot fetch system malloc\n");
exit(1);
}
}
fprintf(fopen("/dev/pts/6","a"),"%s%d%s" ,"malloc(",size,")\n");
return sys_malloc(size);
}
void free(void *p) {
static void (*sys_free)(void *) = NULL;
if (!sys_free) {
if (!(sys_free = (void (*)(void *)) dlsym(RTLD_NEXT, "free"))) {
perror("cannot fetch system free\n");
exit(2);
}
}
fprintf(fopen("/dev/pts/6","a"),"%s%x%s","free(", p,")\n" );
sys_free(p);
}
void glBegin( GLenum mode ){
static void (*m_glBegine)(GLenum) =NULL;
if(!m_glBegine){
m_glBegine= (void (*)(GLenum)) dlsym(RTLD_NEXT,"glBegin");
}
printf ("glBegin(%d)\n",mode);
m_glBegine(mode);
}
any idea why on how to #define RTLD_NEXT ......... ???????????????????
Code: Select all
grep -n RTLD_NEXT /usr/include/dlfcn.h
32:/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
36:# define RTLD_NEXT ((void *) -1l)
Edit: removed annoying 'why GENTOO SUCKS ASS' from subject line --ian!




