From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10322 invoked by alias); 6 Nov 2012 21:50:05 -0000 Received: (qmail 10206 invoked by uid 48); 6 Nov 2012 21:49:49 -0000 From: "adivilceanu at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54791] AIX-only: Constructors are not called in main program. Date: Tue, 06 Nov 2012 21:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: adivilceanu at yahoo dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00520.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791 --- Comment #15 from Adi 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 ?