Linking with nonstandard malloc

Amittai Aviram
Tue Jan 4 23:38:00 GMT 2011

All of you are right on all counts.  I was doing something too stupid to post here, fixed it, and now get the test message as desired.  BTW, yes, I know that glibc's malloc is Doug Lea's malloc, but now I can further doctor my copy of Doug Lea's malloc to do special things.

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 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!

Thanks to everybody!

Amittai Aviram
PhD Student in Computer Science
Yale University
646 483 2639

On Jan 4, 2011, at 5:58 PM, Ian Lance Taylor wrote:

> Amittai Aviram <> writes:
>> Suppose I want to use my own malloc.c and malloc.h for malloc and
>> related functions (based on Doug Lea's code), but use the standard C
>> library (glibc) for all other C library functions.  Is there a way
>> that I can tell the gcc linker to use my malloc code but glibc for
>> everything else?  Thanks!
> It should just work.  If it doesn't, you're going to have to explain
> more clearly precisely what you are doing and precisely what is going
> wrong.
> That said, note that glibc already uses Doug Lea's malloc.
> Ian

More information about the Gcc-help mailing list