public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adivilceanu at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54791] AIX-only: Constructors are not called in main program. Date: Tue, 06 Nov 2012 16:23:00 -0000 [thread overview] Message-ID: <bug-54791-4-YJTPnQv2IA@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-54791-4@http.gcc.gnu.org/bugzilla/> 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.
next prev parent reply other threads:[~2012-11-06 16:23 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-10-03 9:20 [Bug c++/54791] New: " adivilceanu at yahoo dot com 2012-10-03 9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com 2012-10-03 13:47 ` dje at gcc dot gnu.org 2012-11-02 14:49 ` adivilceanu at yahoo dot com 2012-11-02 14:52 ` adivilceanu at yahoo dot com 2012-11-03 6:21 ` adivilceanu at yahoo dot com 2012-11-03 6:24 ` adivilceanu at yahoo dot com 2012-11-03 13:49 ` dje at gcc dot gnu.org 2012-11-03 19:15 ` adivilceanu at yahoo dot com 2012-11-03 22:48 ` dje at gcc dot gnu.org 2012-11-05 14:34 ` adivilceanu at yahoo dot com 2012-11-05 18:55 ` dje at gcc dot gnu.org 2012-11-05 21:14 ` adivilceanu at yahoo dot com 2012-11-06 14:46 ` dje at gcc dot gnu.org 2012-11-06 16:23 ` adivilceanu at yahoo dot com [this message] 2012-11-06 21:50 ` adivilceanu at yahoo dot com 2012-11-07 1:27 ` dje at gcc dot gnu.org 2012-11-07 14:46 ` adivilceanu at yahoo dot com 2012-11-07 15:25 ` adivilceanu at yahoo dot com 2012-11-07 22:15 ` dje at gcc dot gnu.org 2012-11-13 8:21 ` adivilceanu at yahoo dot com 2012-11-13 8:30 ` adivilceanu at yahoo dot com 2012-11-13 14:03 ` dje at gcc dot gnu.org 2012-11-13 14:09 ` adivilceanu at yahoo dot com 2012-11-14 14:20 ` dje at gcc dot gnu.org 2012-11-27 15:54 ` adivilceanu at yahoo dot com 2012-11-27 18:55 ` adivilceanu at yahoo dot com 2012-11-27 19:01 ` adivilceanu at yahoo dot com 2012-11-27 20:42 ` dje at gcc dot gnu.org 2012-11-28 14:01 ` adivilceanu at yahoo dot com 2012-11-28 19:35 ` dje at gcc dot gnu.org 2012-11-29 9:35 ` adivilceanu at yahoo dot com 2012-11-29 9:44 ` adivilceanu at yahoo dot com 2012-12-01 21:42 ` dje at gcc dot gnu.org 2015-03-18 12:42 ` dje at gcc dot gnu.org 2015-03-18 12:49 ` dje at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-54791-4-YJTPnQv2IA@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).