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

--- Comment #53 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-13 20:47:44 
UTC ---
(In reply to comment #52)
> (In reply to comment #51)
> > > If gcc switches from .ctors to .init_array, it needs to make sure to 
> > > generate
> > > the constructors in forward order within the TU, rather than backwards 
> > > order as
> > > it does in the .ctors section. I didn't see anything in HJ's patch that 
> > > does
> > > that.
> > 
> > It uses priority, instead of MAX_INIT_PRIORITY - priority, to generate
> > NNNN for .init_arry.NNNN.
> 
> No, I was talking about order of constructors within a TU without using
> priority. If you have static constructors for A then B in your source file, 
> gcc
> will output B's constructor before A's in the .ctors section, so that A's will
> run first. Where does your patch reverse that to account for the fact that
> .init_array sections are processed in forward order?


Yes, since

1. ld sorts .init_array sections in forward order.
2. ld.so processes .init_array section in forward order.

Reply via email to