http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791
--- Comment #14 from Adi <adivilceanu at yahoo dot com> 2012-11-06 16:22:37 UTC --- Regarding the __attribute__ ((init_priority (NNNN))). Are you sure this works on AIX at namespace level. I think it might work on linux. But on AIX I see no way of that ever working. Here is my understanding on how collect2 works on AIX(correct me if I am wrong): - g++ front end creates one _GLOBAL__I_65535_0_<nameoffirstobject> per object file. Here it is putting all the static constructors that should be called from that object file. - collect2 links (via ld) the whole exe(+libs). Then it is scanning all the _GLOBAL__ and is putting them into the ctors array and generates a functions named _GLOBAL__FI_<exe_name> that will call each _GLOBAL__* entry fro the array in reverse order. So as I see it this whole mechanism can at maximum support priority ordering on a object file basis. (I mean it could sort the _GLOBAL__* entries according to some criteria). Question: How can you influence this criteria? I did a hack and altered the ctors array generated by collect2(in that /tmp//ccGVUVzP.c) and reordered all those _GLOBAL__* entries based on my project needs. Then I recompiled the ccGVUVzP.c file and manually called ld (like g++ is doing the second time). So somehow I simulate the #pragma priority from xlC on a file basis. And the hack worked. Now if you use init_priority for a single global variable in an object file, and use it again on another global in a different object file I do not see how this could work? How would bypass the _GLOBAL__* entries in the ctors array which is already sorted? So my big assumption here is(correct me if I am wrong): On gcc for AIX, all globals from an object file are initialized before globals from another object file are. So you can not have initialization of one global1 from object1.o and then global2 from object2 and then global3 from object1 again. Is my assuption correct? If so a __attribute__ ((init_priority is not ok for what I need. Now regarding the fPIC. I just started using it now. That has changed a lot of stuff. First the _GLOABL__* names are now based on file name rather than name of first object. I am just starting to test this. I will follow up with the results. Thanks for your support.