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: Nick Clifton <nickc at redhat dot com>
- To: Sebastian Huber <sebastian dot huber at embedded-brains dot de>, binutils at sourceware dot org
- Date: Thu, 3 Jan 2019 15:49:21 +0000
- Subject: Re: Does the LD --wrap feature work for library internal references?
- References: <ce008254-fd5c-4b61-4e04-4bc1c0c6f053@embedded-brains.de>
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.
Cheers
Nick