__cxa_atexit question

Steve Ellcey sje@cup.hp.com
Thu May 18 18:34:00 GMT 2006


> I do not know what (or if) system-specific tricks are used to make sure
> that the libCsup.so version of atexit is used instead of the libc.so
> version when a C shared library is incorporated into a C++ application.
>  However, I do see that atexit is reported as WEAK PROTECTED by readelf
> in libc, and as GLOBAL DEFAULT in libCsup.  Perhaps Steve can tell us
> exactly what is being done.

The WEAK does not do anything, the PROTECTED means that if there were a
call to atexit from libc itself it would use the atexit in libc (make a
direct call).  I don't think there are any calls to atexit in libc
though.  So basically, which atexit you get depends on the binding order
of the libraries, the first one found gets used.  Since libc is usually
specified last you should get the libCsup version in all normal cases,
but you could probably make a program pick up the libc version if you
did a link line with -lc before -lCsup.

Steve Ellcey
sje@cup.hp.com



More information about the Libstdc++ mailing list