salem,
thanks for the reply,
i am struggling to use this wrapper in to my program.
Let me show a simple example which i am trying here.
I do have one code test.c as follows
Code:
#include <stdio.h>
int main()
{
char *test;
test = __wrap_malloc(10);
sprintf(test,"testing");
printf("%s",test);
free(test);
return 0;
}
and another testm.c as follows
Code:
#include <stdlib.h>
int numMallocCalls;
void *
__wrap_malloc(int c)
{
numMallocCalls++;
return __real_malloc(c);
}
trying to link them with the following command
Code:
ld -o test testm.o test.o --wrap malloc
it gives me following error
Code:
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094
testm.o: In function `__wrap_malloc':
testm.c:(.text+0x1a): undefined reference to `malloc'
test.o: In function `main':
test.c:(.text+0x32): undefined reference to `memcpy'
test.c:(.text+0x47): undefined reference to `printf'
test.c:(.text+0x53): undefined reference to `free'
can you please let me know where am i going wrong here ..?