This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH COMMITTED: Implement constructor priorities in gold
"Matt Rice" <ratmice@gmail.com> writes:
> On Fri, Mar 28, 2008 at 4:21 PM, Michael Hennebry
> <hennebry@web.cs.ndsu.nodak.edu> wrote:
>>
>> What are constructor priorities?
>> Google produces several results,
>> including comments to the effect that some compiler
>> or another doesn't implement them correctly,
>> but nothing informative to me.
>>
>
> it is my possibly naive interpretation that constructor priorities
> allow you to specify the order in which constructors are called,
Yes.
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html
search for "constructor (priority)".
> this may not be the appropriate place to mention this but i noticed
> the documentation on constructor priorities do not specify what the
> default constructor priority is and was left wondering
It's intentionally left undefined. What happens today is that the
objects which appear first in the link command have their constructors
run first. However, when several different objects are included from
a single archive file, it is difficult to predict which one's
constructors will be run first. Destructors are run in the reverse
order of constructors.
Ian