http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770

--- Comment #46 from Mark Mitchell <mark at codesourcery dot com> 2010-12-12 
18:40:35 UTC ---
On 12/11/2010 4:32 PM, hjl.tools at gmail dot com wrote:

> Mark, I may have misunderstood you. Correct me if I am wrong.
> Currently, it may be possible to interleave constructors
> between different object files by examing .ctors section names
> and passing object files in specific order to linker.

It is possible.  The linker sorts the section names, so a higher
priority constructor always runs before a lower priority constructor,
independent of object file order.  You may also be able to play games
with object file order to control the order of constructors with the
same priority, but we don't document that anywhere, as far as I know.

> But we can't do it between .init_array and .crors sections.

Correct, we do not at present do that.  That's the problem I'm raising
with switching to .init_array.  If you do that, and someone links in old
object code using .ctors, we may run a low-priority .ctors constructor
after a high-priority .init_array constructor, or we may run a
low-priority .init_array constructor after a low-priority .ctors
constructor.  Either outcome would be a bug; we would break semantics.

My opinion is that we can't switch to .init_array unless we either (a)
make the linker detect the problem and fix it, or (b) at least make the
linker detect the problem and issue an *error*.  I do not think a
warning is sufficient.

Reply via email to