From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18805 invoked by alias); 30 Nov 2010 15:16:27 -0000 Received: (qmail 18788 invoked by uid 22791); 30 Nov 2010 15:16:26 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Nov 2010 15:16:22 +0000 From: "mschulze at ivs dot cs.ovgu.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/45263] registers used in __do_global_ctors can get clobbered 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: normal X-Bugzilla-Who: mschulze at ivs dot cs.ovgu.de X-Bugzilla-Status: UNCONFIRMED 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 Date: Tue, 30 Nov 2010 15:22:00 -0000 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: 2010-11/txt/msg03688.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263 --- Comment #7 from Michael Schulze 2010-11-30 15:16:20 UTC --- Created attachment 22579 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22579 alternative patch using register r15 instead of r20 avoids pushing/poping In reaction to bug 29141, which is still pending and not fixed, I offer a patch that corrects the handling of global constructors. The fix proposed in bug 29141 leads to wrong handling of global constructors since gcc version 4.4.0. And this is independent of the 64kB boundary because the handling is always wrong. With the first provided patch the register r20 was always pushed and popped but this is not necessary. The global-constructors patch avoids this and uses r15 instead of r20. Due to the compiler abi the register r15 is left unchanged by called routines, and it has to be saved/restored by routines that use it. I applied the global-constructor patch and then the compiler generates correct code for the execution of global constructors regardless of whether the constructor is located below or above 64kB. I tested the patch by my own but I think it needs further tests. Please try it out. I think without such a patch independent of using my one or the r20 patch, this bug is a show stopper since gcc version 4.4.0.