ld, --wrap and dynamic library

Cournapeau David cournape@atr.jp
Thu Jul 28 06:25:00 GMT 2005


Hello,

	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.

	Thank you for your help,

	David



More information about the Binutils mailing list