Article View: comp.sys.next.programmer
Article #691How do I override malloc with the C compiler?
From: Nelson Minar
Date: Tue, 14 Apr 1992 22:18
Date: Tue, 14 Apr 1992 22:18
30 lines
1741 bytes
1741 bytes
I'm compiling a simple stdio-only program on a NeXT box. One of the
modules of the program is my own version of malloc(), free(), and
realloc().
When I go to link my program, I get errors from the linker claiming
that malloc() is redefined. If I don't link in my own version of
malloc(), it links fine, albeit without the code I want.
The NeXT OS is the first system I've gotten these errors - most OSs
will use my malloc() and never link in the standard malloc(). From
what I've read of the ld man page, it should work the way I want it
to. I'm guessing the problem is general - how do I override standard
library routines in C code? I'd prefer email responses.
cc -o main main.o malloc.o
/bin/ld: multiple definitions of symbol _realloc
malloc.o definition of _realloc in section (__TEXT,__text)
/lib/libsys_s.a(malloc.o) definition of absolute _realloc (value 0x5002d7a)
/bin/ld: multiple definitions of symbol _malloc
malloc.o definition of _malloc in section (__TEXT,__text)
/lib/libsys_s.a(malloc.o) definition of absolute _malloc (value 0x50028fa)
/bin/ld: multiple definitions of symbol _free
malloc.o definition of _free in section (__TEXT,__text)
/lib/libsys_s.a(malloc.o) definition of absolute _free (value 0x5002546)
cc -o main main.o
[no errors]
--
__
nelson@reed.edu \/ Shop as usual and avoid panic buying
Technical Details
Message-ID:
<1992Apr14.221833.13899@reed.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!reed!nelsonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!reed!nelson From: nelson@reed.edu (Nelson Minar) Newsgroups: comp.sys.next.programmer Subject: How do I override malloc with the C compiler? Message-ID: <1992Apr14.221833.13899@reed.edu> Date: 14 Apr 92 22:18:33 GMT Article-I.D.: reed.1992Apr14.221833.13899 Organization: Reed College, Portland, OR Lines: 30