[patch] init_array/fini_array support

John Bowler jbowler at acm.org
Wed Feb 1 19:31:23 UTC 2006


From: Peter S. Mazinger
>I am thinking here of __h_errno_location, __errno_location and 
>__pthread_initialize_minimal() in __uClibc_main.c, because those are also 
>present within libpthread.so.

Isn't the issue here that the libpthread implementation of these
things *must* be used?  (To ensure that errno is per-thread not
per-address-space?)  I don't think your approach would do that,
if I understand it correctly.

If it doesn't matter which gets used then there is no problem - the
first one will be used.  If it does then, originally, making the libc
one weak would have worked reliably.  A strong definition would
override the libc one and if two modules both tried to make a strong
definition that should fail.  (On the other hand, I don't think it
does fail...)

So, if I'm correct and assuming there is some objection to putting
the weak handling back into ld.so (I can't see why, OpenEmbedded has
been running that way for months), the answer is something of the
form:

libpthreads.so:

int *__strong_errno_location() {
   /* the correct libpthreads implementation */
}

/* no definition of __errno_location */

libc.so:

extern int * (weak __strong_errno_location) ();
  /* i.e. a weak reference to a strong symbol */

int *__errno_location() {
   if (__strong_errno_location != 0)
      return __strong_errno_location();
   /* do the old implementation */
}

I.e. in libc check to see if there is an alternate implementation.

This code is effectively implementing 'strong' definitions
in C - that seems a waste of time to me since they can be
implemented in ld.so!

The code also has a significan overhead - the extra test on each
reference to (errno), it's doing run-time-weak rather than
dynamic-link-time-weak!

John Bowler <jbowler at acm.org>




More information about the uClibc mailing list