bd satish <bdsat...@gmail.com> writes:

> [...]
> The following piece of code, gives "undefined references" to
> __real_malloc, __real_free, etc.:
> Compiled with:
> g++ -fmudflap references.cc -lmudflap
>
> /lib64/libmudflap.a(mf-runtime.o): In function `__mfu_check':
> ../libmudflap/mf-runtime.c:912: undefined reference to `__real_malloc'
> [...]

According to libmudflap/mf-impl.h, since you're using ordinary
archives rather than shared libraries (-fPIC) these __real_FOO
functions are expected to be provided by the linker:

   (1) The static method involves a list of -wrap=foo flags being passed to
   the linker, which then links references to "foo" to the symbol
   "__wrap_foo", and links references to "__real_foo" to the symbol "foo".
   When compiled without -DPIC, libmudflap.a contains such __wrap_foo
   functions which delegate to __real_foo functions in libc to get their
   work done.

So, something appears wrong with this wrapping mechanism in your case.
Can you rerun g++ with -v to see how the linker is invoked?  Perhaps
there is something missing for the C++ static-linking case.


- FChE

Reply via email to