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?


Hello Nick,

On 03/01/2019 16:49, Nick Clifton wrote:
Hi Sebastian,

For another it doesn't work:

/build/rtems/5/bin/powerpc-rtems5-gcc -Wl,--wrap=_bsd_ether_output -qrtems -B/build/rtems/5/powerpc-
It links, I would have expected an undefined reference to __wrap__bsd_ether_output. In the executable I find this:

nm media01.exe | grep ether_output
0001b640 T _bsd_ether_output

It is not clear to me why it works with one function and not with another.
Is it possible that the _bsd_ether_output function has been inlined into
all the places where it is used ?

The wrap feature of the linker works by replacing symbols, but this is
only effective if there are undefined references to the symbols being
replaced.  If all of the references have already been resolved (or just
don't exist, eg because of inlining) then wrapping will have no effect.

It is not unlined, but its only reference is done via a function pointer assignment here:

https://git.rtems.org/rtems-libbsd/tree/freebsd/sys/net/if_ethersubr.c#n950

[...]|
/*||
 * Perform common duties while attaching to interface list ||||
 */ |

|void ether_ifattach(struct ifnet *ifp, const u_int8_t *lla) { int i; struct ifaddr *ifa; struct sockaddr_dl *sdl; ifp->if_addrlen = ETHER_ADDR_LEN; ifp->if_hdrlen = ETHER_HDR_LEN; if_attach(ifp); ifp->if_mtu = ETHERMTU; ifp->if_output = ether_output; ifp->if_input = ether_input; |[...]

Does the wrap feature work for function pointer assignments?

--
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]