This is the mail archive of the binutils@sourceware.org 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: wrap function and its caller in the same object file with ld ?


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


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