GNU ld --wrap limitations

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jan 14 09:22:44 UTC 2019


Hello,

while testing the event recording with the libbsd I noticed a GNU ld 
--wrap limitation:

https://www.sourceware.org/ml/binutils/2018-12/msg00210.html

It turned out that the wrapping doesn't work for references internal to 
a translation unit. My hope was that the RTEMS Trace Linker doesn't have 
this limitation, but the documentation says (user manual):

"The trace linker’s major role is to wrap functions in the existing 
executable with trace code. The
directions on how to wrap application functions is provided by the 
generator configuration. The
wrapping function uses a GNU linker option called –wrap=symbol."

In the libbsd a lot of things are done through function pointer 
assignments, e.g.

static struct netisr_handler ip_nh = {
     .nh_name = "ip",
     .nh_handler = ip_input,
     .nh_proto = NETISR_IP,
#ifdef    RSS
     .nh_m2cpuid = rss_soft_m2cpuid_v4,
     .nh_policy = NETISR_POLICY_CPU,
     .nh_dispatch = NETISR_DISPATCH_HYBRID,
#else
     .nh_policy = NETISR_POLICY_FLOW,
#endif
};

or

/*
  * 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;

This makes the tracing quite ineffective in this area.

-- 
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 at embedded-brains.de
PGP     : Public key available on request.

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



More information about the devel mailing list