This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Does the LD --wrap feature work for library internal references?
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Nick Clifton <nickc at redhat dot com>, binutils at sourceware dot org
- Date: Fri, 4 Jan 2019 08:03:50 +0100
- Subject: Re: Does the LD --wrap feature work for library internal references?
- References: <ce008254-fd5c-4b61-4e04-4bc1c0c6f053@embedded-brains.de> <652b60f1-9606-0c56-aa32-117d727c1caf@redhat.com>
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.