Custom malloc/mmap for x86_64

Sat Apr 28 23:47:00 GMT 2012

Thank you guys for your quick replies. I have a separate library already 
working independently that supports my work. I was asked to migrate
 it to glibc to provide an actual implementation and deploy it on a 
real system. 

So to answer your questions: my_malloc and malloc, as well as 
my_mmap and mmap all have to be supported and may be called 
at any time. Whenever free() is called, it works perfectly since both
 malloc and my_malloc operate over the same data structures, 
so I do not have to worry about keeping track of space that way. 
Moreover, malloc and my_malloc can grow the same 
heap/virtual address space for the given process. 

So, basically, we just need to overload the above methods. I do not want 
to overwrite mmap nor malloc. I know how to do that via the -wrap flag 
as you guys mentioned. I also know about LD_PRELOAD variable.

But, back to my old question. Out of curiosity because I like to
 know how things really work. How does glibc exaclty generate
 wrappers for mmap, munmap, et al.?

I know the script creates syscall wrappers for
 the methods specified in syscalls.list. But when I looked in there
 I did not see mmap, munmap, sbrk, etc.

Thank you all!

More information about the Libc-help mailing list