This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54791] AIX-only: Constructors are not called in main program.
- From: "adivilceanu at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Nov 2012 21:49:47 +0000
- Subject: [Bug target/54791] AIX-only: Constructors are not called in main program.
- Auto-submitted: auto-generated
- References: <bug-54791-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791
--- Comment #15 from Adi <adivilceanu at yahoo dot com> 2012-11-06 21:49:47 UTC ---
This is a follow up on comment 14.
It seems that -fPIC dramatically improved the way constructors are called. It
seems that the linker has some logic and is initializing the globals from
various object files in a correct order.(it somehow checks the dependencies
betweeen globals I assume). I don't know how this is happening yet. As I see
the ctors array has the same elements(except for the generated name that has
changed), so something other then the ctors list is involved here. Do you know
what?
Now this works on my exe that is linked with static libs. Now if I go and link
my exe with the shared version of my libs than it is not working.
I saw this is because first all the constructors from the exe are called first
and only after that constructors from the shared libs are called. But as I said
I need some objects from the shared lib constructed first before objects in the
main exe are initialized. Do you know how I can solve this case ?