This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld, --wrap and dynamic library
- From: Ian Lance Taylor <ian at airs dot com>
- To: Cournapeau David <cournape at atr dot jp>
- Cc: binutils at sources dot redhat dot com
- Date: 28 Jul 2005 09:30:50 -0700
- Subject: Re: ld, --wrap and dynamic library
- References: <1122532228.11904.19.camel@localhost.localdomain>
Cournapeau David <cournape@atr.jp> writes:
> I have some questions concerning the --wrap option of the GNU linker,
> and about the possibility to use it on dynamic libraries.
>
> I would like to be able to do the following:
>
> - libfoo.so provides the function do_foo(), which uses malloc/free.
> - foo is a program using libfoo.
>
> I want to wrap all malloc calls done in the program foo, including
> malloc calls in libfoo. If I am using the --wrap option
> of the GNU linker, I managed to wrap all malloc calls done in all
> .o linked into foo, but not the ones in libfoo.so.
>
> Is there a way to use the --wrap even for .so files ? When I look at
> the symbols of libfoo.so, I see that the symbol malloc is
> replaced by malloc@@GLIBC_2.0, which is why, I guess, the wrap
> option of ld doesn't replace the malloc call by __wrap_malloc in the
> dynamic library.
libfoo.so has already been fully linked and the references to malloc
have been resolved, so the --wrap option is ineffective.
Ian