This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld, --wrap and dynamic library


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]