PATCH COMMITTED: Implement constructor priorities in gold

Matt Rice ratmice@gmail.com
Sat Mar 29 00:35:00 GMT 2008


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,

imagine the situation where you have libA and libB both with constructors

libB has a dependency and calls a function from libA in its constructor.

libA's implementation of the called function depends upon the
constructor being run

now afaik the order in which constructors are called is not defined
will libA's constructor get called before libB's constructor or libB's
constructor get called before libA's.

iirc I have seen both of these interpretations so without priorities
the only safe thing is to insure in the called function that the
constructor has been indeed called, or require massaging of the link
order to ensure that libA gets loaded first before libB..

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



More information about the Binutils mailing list