This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __cxa_atexit question


Although it is possible to make something along these lines work, and
I have the gcc/config/darwin-crt3.c running on Mac OS 10.3.9 as an
example, there are some limitations:

1. You need both a shared library, to hold global variables (in the
   case of Darwin, the system has KeyMgr which provides this
   functionality) and also a .o file linked into every executable;
2. You need hidden visibility support;
3. You need to be able to require that all dynamic objects be re-linked with
   the new .o if they're to have their atexit() calls properly coordinated
   (and that means *all* objects, not just the C++ ones);
4. You need to be able to call the system atexit() from each local copy of
   atexit(), or some other way to actually get your code called at exit.

Point (4) means you pretty much have to do it separately for each
target, or at least each object file format, since dlsym is not
sufficiently standardized.  Point (3) means you can't just do it in
libstdc++ or libsupc++, you have to do it in GCC itself.  Point
(1) means (except for Darwin) that you can't ship stand-alone
executables any more, because you need the shared library.

Having had the experience I find that this is a poor second choice
compared to just having the support in libc.  You'll notice that in
Mac OS 10.4 and higher, we have support in libc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]