https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52477

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iains at gcc dot gnu.org

--- Comment #17 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #6)

I was looking into this area trying to diagnose/solve a testsuite fail on
Darwin (see pr91087).

> 
> I would expect A B C, and gcc currently outputs B A C.

I assume that's because the SysV ABI says:
"Termination functions specified by users via the atexit mechanism must be
executed before any termination functions of shared objects.” 

and, therefore (for PIC at least) we would get incorrect nesting of CTORs and
DTORs if the __attribute__((constructor)) was not run first.

>  Instead of emitting
> constructor functions directly into .init_array as we do now, we should
> remember them and call them from __static_initialization_and_destruction_0.

Implementing this would probably also provide a workaround for the Darwin bug
(by avoiding the use of special sections for the attributed ctor/dtors.

Is there any specification that demands a specific section for the
__attribute__((constructor/destructor))s?

Reply via email to