Mail Archives: djgpp/1999/12/14/16:30:25
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello,
I can't get the linker command --wrap to work with C++. The following
program compiles perfectly if I name it test.c, but produces linker
errors if I name it test.cc. Does --wrap only work with C, or am I doing
something wrong? I couldn't find anything in the docs saying it
shouldn't work. (FYI, gcc -v says "gcc version 2.95.1 19990816
(release)"). Here is my program, the command line and the error
messages:
-------- source file: test.cc ---------
#include <stdlib.h>
extern void *__real_malloc(size_t size);
void *__wrap_malloc(int c)
{
return __real_malloc(c);
}
int main(void)
{
free(malloc(4711));
return 0;
}
-------- eof(test.cc) -----------------
command line:
gcc -Wl,--wrap,malloc -o test.exe test.cc -W -Wall
-------- error messages ---------------
test.o(.text+0xe):test.cc: undefined reference to
`__real_malloc(unsigned long)'
test.o(.text+0x33):test.cc: undefined reference to `__wrap_malloc'
d:/djgpp/lib/libgcc.a(frame.o): In function `frame_init':
frame.c(.text+0x3fe): undefined reference to `__wrap_malloc'
frame.c(.text+0x40a): undefined reference to `__wrap_malloc'
d:/djgpp/lib/libgcc.a(frame.o): In function `execute_cfa_insn':
frame.c(.text+0x8d6): undefined reference to `__wrap_malloc'
d:/djgpp/lib/libgcc.a(frame.o): In function `__register_frame':
frame.c:627: undefined reference to `__wrap_malloc'
d:/djgpp/lib/libgcc.a(frame.o):frame.c:627: more undefined references to
`__wrap_malloc' follow
collect2: ld returned 1 exit status
make.exe: *** [test.exe] Error 1
-------- end of error messages --------
Thanks for help,
Sven Sandberg
- Raw text -