This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: wrap function and its caller in the same object file with ld ?
- From: Ian Lance Taylor <iant at google dot com>
- To: MickaÃl MASSON <mickael dot masson at orange-ftgroup dot com>
- Cc: <binutils at sourceware dot org>
- Date: Mon, 07 Apr 2008 13:06:58 -0700
- Subject: Re: wrap function and its caller in the same object file with ld ?
- References: <200804070942.m379gQLj011684@smtp.silicomp.fr>
MickaÃl MASSON <mickael.masson@orange-ftgroup.com> writes:
> For this, I use the powerful linker ld and its wrap option (-wrap). So, for
> each function call, we call the wrap function containing printf() for
> arguments and result and the call for the real function. It's very
> convenient because we don't modify source files in this way : we just add
> some code apart and, for debugging, it's very useful.
> It works perfectly except when the function to trace is in the same object
> that the caller to this function.
> In fact, this is not abnormal because linkage is the last step before to
> obtain the executable and its aim is to solve undefined references to
> functions. Consequently, when a function and its caller are in the same
> object, the reference is not undefined !
>
> That's why I would like to know if it's possible to undefine function calls
> for a particular function in object files in order to wrap this function.
> Or maybe there is another way to do this ?
As you probably know, this is a documented restriction on --wrap. The
problem is that on some targets the assembler will fully resolve the
reference to the wrapped function. When that happens, there is
nothing the linker can do. You have to get the assembler to change
its behaviour.
Ian