internal calls to malloc(), free() from uclibc should go to uclibc implementation

Carmelo Amoroso carmelo73 at gmail.com
Sat Apr 30 20:35:47 UTC 2011


On 30/04/11 21:26, Saurov Shyam wrote:
> I have an uClibc wrapper library which does an implementation of malloc(), realloc() and f
ree() that embedded some statistics gathering about memory allocations and then use the real malloc(), realloc(), free()
definition of uClibc to perform the memory allocationand itself only embed the necessary logic to implement the
statistics gathering function. The wrapper library is statically linked with the application. Please note that the
intention of the wrapper is to hook and gather statistics only those calls which are going out of application.code
snippet: uclibcmalloc = dlsym(RTLDNEXT, “malloc”); uclibcrealloc = dlsym(RTLDNEXT, “realloc”); uclibcfree =
dlsym(RTLDNEXT, “free”);void * malloc(sizet sz) { … p = uclibcmalloc(sz); … return p;} void * realloc(void * oldp, sizet
sz) {… p = uclibcrealloc(oldp, sz); … return p;} void free(void * p) { … uclibcfree(p); } malloc() and free() are
working perfectly. But when realloc() is called the problem arises. The
>  uClibc realloc()internally calls malloc() for allocating the new pointer and free() to free the old pointer. When this malloc() and free() are getting called they are coming to my wrapper library
implementation.I am expecting that the internal calls to malloc(), free() from uclibc should go to uclibc implementation
directly, but it is not happening that way. Please advice, how to get rid of this issue. I want uClibc internal function
calls should go to uClibc implementation only. Regards,AviDear uclibc ! Get Yourself a cool, short @in.com Email ID now!
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc


Hi,
you should really ry to fix your emil clieant by properly wrapping line.

Anyway, the problem seems to be related to a missing hidden_proto / hidden_def
for the functions (malloc / free) that are used internally in the libc.

I don't have the code here to check it.

Carmelo



More information about the uClibc mailing list