This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
wrap functions in glibc
- From: "吴曦" <wu dot andrew dot xi at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 21 Nov 2007 19:42:52 +0800
- Subject: wrap functions in glibc
Hi
As indicated in gcc maunal and ld manual,
Using "-Wl,--wrap -Wl,wraper_func_name" can provide a wrapper function
for certain interface in the program. However, I found this doesn't
work for function calls in the shared library.
for example, if I use
-Wl,--wrap -Wl,malloc
to wrap the malloc function, I can wrap the calls to malloc in my
code, but the malloc called in library cannot be wrapped. I think this
is because --wrap option is managed by linker, while it cannot replace
calls to malloc in library with wrapper functions.
However, if I want to wrap function calls in library (e.g. memcpy),
what should I do?
Any hints on this problem is truly appreciated.
Andrew