This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

duplicate static ctor/dtor function emission


Hi -

While working on some mudflap instrumentation problem,
I noticed that mainline has sometime recently started
emitting some static ctor/dtor functions twice.  Users
of the function "cgraph_build_static_cdtor", which
includes mudflap, java, and c-decl itself are affected.

The problem with this function is that it both ...

(a) sets DECL_STATIC_CONSTRUCTOR/DESTRUCTOR of the decl,
    which means that during the subsequent cgraph_finalize_function 
    call (and maybe also tree_rest_of_compilation alternative), 
    c_expand_body is eventually called.  c_expand_body emits the
    first copy:

        .section        .ctors,"aw",@progbits
        .align 8
        .quad   <ctor-function-symbol>

(b) then calls targetm.asm_out.constructor/destructor directly, emitting

        .section        .ctors.65436,"aw",@progbits
        .align 8
        .quad    <ctor-function-symbol>

This means that the given function will be called twice.  Note that in this
example (taken from mudflap), the initialization priority number is used
for the second call, but is not respected during the first.

Question: Does c_expand_body really need the ctor/dtor handling right there?
Could this be just a mainline merge artifact?


- FChE


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