Amittai Aviram <amittai.aviram@xxxxxxxx> writes: > Point of information: malloc and the other routines (or rather > dlmalloc, etc.) are thus defined both in my local source file > (malloc.c) and in the glibc.a or glibc.so object code. How does the > linker know to use my local malloc definitions instead of the ones in > glibc--since I otherwise have to use glibc functions and am #including > stdlib.h? Thanks! There are two cases: static linking (if you use the -static option) and dynamic linking (the default). When linking statically the linker will see your version of malloc first, and will not pull in the version from libc. When linking dynamically, then, assuming you are using an ELF based system such as GNU/Linux, the dynamic linker will use symbol interposition to redirect all calls to the version of malloc in your program rather than the one in the system library. The dynamic linking mechanism used on ELF is designed specifically to make this sort of thing work. Ian