[uClibc] __cxa_atexit/__cxa_finalize complete implementation

Stephen Warren swarren at wwwdotorg.org
Mon Aug 15 21:12:20 UTC 2005


I have completed an implementation of __cxa_atexit and __cxa_finalize.
The diff against the latest svn tree is attached.

This has been tested using:

a) A compiler built with --disable-__cxa_atexit, but building code using
-fuse-cxa-atexit

b) A compiler built with --enable-__cxa_atexit (built using buildroot,
just by changing all --disable-__cxa_atexit to --enable-__cxa_atexit in
toolchain/gcc/gcc-uclibc-3.x.mk

Code compiled/tested:

a) A C++ test app with a bunch of global ctors/dtors, interacting with
ctors/dtors for static C++ objects at function scope

b) The app in (a) linked against a .so file with a global C++ object
with a ctor/dtor

c) The app in (a) loading the .so added in (b) using dlopen/dlclose.

d) Our real heavily multi-threaded heavily C++ app with lots of global
and static-function-level ctors/dtors.

I have tested on i386 only, with UCLIBC_DYNAMIC_ATEXIT=y. I don't see
why other architectures/settings shouldn't work.

Possible issues:

* I included <bits/atomicity.h> to implement __cxa_finalize (I need
compare_and_swap). When I do a non-debug build of uClibc, this file
generates warnings saying "warning: matching constraint does
not allow a register". When I build a debug uClibc, this file generates
an errot!

* The new code relies on a definition of __dso_handle (although,
actually, atexit() references it weakly, so it's probably OK if it
doesn't exist.) Typically, this is provided by gcc's crtbegin.o. I
noticed (based on filenames in the uClibc source) that for some
architectures, uClibc provides this object (e.g. nios). So, we may need
to add the __dos_handle definition to those custome crtbegin.o files.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclibc_cxa_atexit-svn.patch
Type: text/x-patch
Size: 9124 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20050815/18cf8dfc/attachment.bin 
-------------- 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/20050815/18cf8dfc/attachment.pgp 


More information about the uClibc mailing list