Re: New nvidia drivers available

From: Doug Rabson <dfr_at_nlsystems.com>
Date: Sun, 15 Aug 2004 16:27:03 +0100
On Sunday 15 August 2004 16:16, Justin T. Gibbs wrote:
> >> I thought that static constructor invocation was deterministic
> >> based on link order.  Does the C++ spec really indicate that the
> >> order of construction can be random?
> >
> > I don't think the spec places any restrictions on constructor
> > ordering. The problem here is that you get different behaviour
> > depending on whether you link with libGL first followed by
> > libpthread (in that case libpthread initialises first) or if you
> > link in the other order (in which case libGL initialises first). As
> > far as I can see, rtld calls the _init sections of each shared
> > library in reverse order with the last library linked against being
> > initialised first.
>
> But such ordering restrictions also apply to things like weak
> symbols, so I don't think that imposing a link order restriction to
> solve this issue is really a problem.

The algorithm for weak symbols is pretty simple - you always get either 
the first strong symbol that rtld finds in its search or the last weak 
symbol. I think we arrange for stuff like open(2) to be weak in libc 
and strong in libpthread.

>
> >From my Microsoft days, I know that at least PowerPoint took
> > advantage
>
> of the known order of static constructor invocation.  The splash
> screen was executed from a static constructor in the first .o linked
> into the executable.  I'm just curious if this is something the C++
> spec says anything about.  I'd be surprised if it didn't.

I'm sure that constructor ordering differs between binutils toolchains 
on unix systems and Microsoft toolchains on win32 systems. The software 
I write in my day job uses C++ constructors heavily and I'm certain 
that things get constructed in a different order on the two platforms. 
We just accept it and write code that can initialise in any order.
Received on Sun Aug 15 2004 - 13:26:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:06 UTC