GNU ld --wrap limitations

Sebastian Huber sebastian.huber at
Mon Jan 14 09:22:44 UTC 2019


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

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,
     .nh_policy = NETISR_POLICY_FLOW,


  * Perform common duties while attaching to interface list
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;
     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
PGP     : Public key available on request.

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

More information about the devel mailing list