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: Does the LD --wrap feature work for library internal references?


On 10/01/2019 14:08, Alan Modra wrote:
On Thu, Jan 10, 2019 at 01:14:22PM +0100, Sebastian Huber wrote:
from the documentation

"Use a wrapper function for symbol. Any undefined reference to symbol will
be resolved to __wrap_symbol. Any undefined reference to __real_symbol will
be resolved to symbol. "
Note "undefined reference".  The references you want wrapped should
not be defined in the same file.

In my example there is a file "f.c":

#include "f.h"

#include <stdio.h>

func f(void)
{
    puts(__PRETTY_FUNCTION__);
    return g;
}

There is also a "g.c":

#include "f.h"

#include <stdio.h>

void g(void)
{
    puts(__PRETTY_FUNCTION__);
}

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


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