> I have written wrapper functions for some predefined library functions in C.> Can anybody help me how do I build the sourcecode of gcc with new> functions and how to link my wrapper lib prior to standard lib? Do I> to change makefile settings??>> Ex:> 1) wrapper function file:> wrapper.c>> void *malloc(size_t size) {> -----> return (malloc(size));> -----> }

This isn't strictly a compiler question, and it depends some on your
environment.

GNU libc on modern ELF-based Linux creates symbols named __libc_malloc
and the like for most functions, then exports "malloc" as a weak alias
for __libc_malloc. I've certainly written:

to debug runtime issues. Then I built this as a shared library and
loaded it using the Linux dynamic loader's LD_PRELOAD environment
variable.

_Linkers and Loaders_ (sect. 6.4) also mentions that "UNIX linkers and
many MS Windows linkers take an intermixed list of object files and
libraries on the command line...and process each in order" and mentions
that you could use this technique by including -lmymalloc before -lc on
the linker command line. I can't find any specific documentation of
this in the GNU ld manual, though.

--dzm
[That last technique is in the folklore. It won't work if libc has its internal
references already bound, but on a modern system I doubt that it will. -John]