http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
--- Comment #37 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-12 00:00:53 UTC --- (In reply to comment #36) > > That is the constructor order between A and B. We don't support > > "interleaving constructor priorities" between object files. > > Yes, we do. We have for a very long time. This is why the linker sorts > the .ctors sections. Really? Here is a testcase. Do you think goo's constructor will be called before another constructor in another file with priority 1005? [...@gnu-6 pr46770-2]$ cat foo.C class Two { private: int i, j, k; public: static int count; Two( int ii, int jj ) { i = ii; j = jj; k = count++; }; Two( void ) { i = 0; j = 0; k = count++; }; int eye( void ) { return i; }; int jay( void ) { return j; }; int kay( void ) { return k; }; }; extern Two foo; extern Two goo; Two foo __attribute__((init_priority(65530))) ( 5, 6 ); Two goo __attribute__((init_priority(65535))) = Two( 7, 8 ); [...@gnu-6 pr46770-2]$ gcc -c foo.C -m32 [...@gnu-6 pr46770-2]$ readelf -S foo.o | grep ctor [ 8] .ctors.00005 PROGBITS 00000000 0000f8 000004 00 WA 0 0 4 [ 9] .rel.ctors.00005 REL 00000000 000770 000008 08 17 8 4 [10] .ctors PROGBITS 00000000 0000fc 000004 00 WA 0 0 4 [11] .rel.ctors REL 00000000 000778 000008 08 17 10 4 [...@gnu-6 pr46770-2]$