why debian uses --use-cxa-atexit

Nathan Sidwell nathan@codesourcery.com
Sun Jun 2 10:50:00 GMT 2002


Jakub Jelinek wrote:
> 
> It is not about being or not being accurate for gcc 3.1, it is about glibc
> 2001-02-26 or later having:
> 
> /* This is defined by newer gcc version unique for each module.  */
> extern void *__dso_handle __attribute__ ((__weak__));
> 
> /* Register FUNC to be executed by `exit'.  */
> int
> atexit (void (*func) (void))
> {
>   return __cxa_atexit ((void (*) (void *)) func, NULL,
>                        &__dso_handle == NULL ? NULL : __dso_handle);
> }
it is the address of  __dso_handle which is needed. We'd misinterpreted
the spec until Mark applied
2002-04-15  Mark Mitchell  <mark@codesourcery.com>

        * decl.c (register_dtor_fn): Pass the address of dso_handle, not
        dso_handle itself, to __cxa_atexit.

so that call should really be
  return __cxa_atextit ((void (*) (void *)) func, NULL, &__dso_handle);

(previously __dso_handle was inited to its own address, so your
code would work for g++ produced objects, but not necessarily for others.)

nathan
nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org



More information about the Gcc mailing list