__cxa_atexit and __cxa_finalize implementation

Stephen Warren swarren at wwwdotorg.org
Wed Sep 14 03:40:14 UTC 2005


Joakim Tjernlund wrote:
>>From: Stephen Warren [mailto:swarren at wwwdotorg.org]
>>
>>Joakim Tjernlund wrote:
>>
>>>Stephen Warren wrote:
>>>
>>>>Did anyone have any feedback on this? Is it likely to get merged, or are
>>>>there problems with it?
>>>
>>>
>>>+/* Hide the symbol so that no definition but the one locally in the
>>>+   executable or DSO is used.  */
>>>+#ifdef HAVE_DOT_HIDDEN
>>>+asm (".hidden\tatexit");
>>> #endif
>>>
>>>Just had a quick look as I don't have much time ATM, but here goes:
>>> Why do you hide atexit?
>>> If you must hide it, use attribute_hidden instead.
>>
>>Because glibc does it, of course:-)
>>
>>But I think the reasoning is this:
>>
>>Every app/DSO gets its own __dso_handle. This identifies which atexit
>>routines are tied to each DSO, so when a DSO unloads, only the atexit
>>routines registered by that DSO are run - the others are left around.
>>
>>atexit() references __dso_handle. If code in a DSO calls atexit(), the
>>definition of __dso_handle for that DSO must be used (since __dso_handle
>>is also hidden). To achieve this, we make atexit() hidden, so each
>>app/DSO gets its own copy, that references the correct app/DSO-specific
>>version of __dso_handle.
> 
> Unless I have forgotten all about hidden symbols, you are making atexit local to libc. atexit won't
> be visible to other apps/libs. Is that what you want? I figured atexit was mandatory, but that's
> just a guess.

Ah yes, I guess that doesn't work quite right.

glibc stores atexit.o (and hence the atexit function) into
libc_nonshared.a, so a copy of atexit() is included directly into each
DSO/app at link time, rather than atexit() being placed into libc.so and
dynamically resolved.

I guess my patch doesn't do this to atexit() in uClibc.

My built copy of uClibc (0.9.27 at least) doesn't seem to have an
equivalent to libc_nonshared.a :-( I wonder how to get equivalent
functionality...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20050913/683dda51/attachment.pgp 


More information about the uClibc mailing list