[patch] init_array/fini_array support
Joakim Tjernlund
joakim.tjernlund at transmode.se
Wed Feb 1 23:03:21 UTC 2006
> 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 */
> }
You can do this a little better:
extern int * (weak __strong_errno_location) ();
int * (*my_errno_location) () = __strong_errno_location;
at init do:
if (!my_errno_location)
my_errno_location = my_old_errno_location;
then use in your code:
my_errno_location();
Jocke
>
> 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