From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19447 invoked by alias); 5 May 2011 14:13:00 -0000 Received: (qmail 19417 invoked by uid 22791); 5 May 2011 14:12:56 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-pv0-f169.google.com (HELO mail-pv0-f169.google.com) (74.125.83.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 May 2011 14:12:37 +0000 Received: by pvc12 with SMTP id 12so1405465pvc.0 for ; Thu, 05 May 2011 07:12:36 -0700 (PDT) Received: by 10.68.20.106 with SMTP id m10mr3339542pbe.137.1304604756283; Thu, 05 May 2011 07:12:36 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id y8sm1459750pba.51.2011.05.05.07.12.34 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2011 07:12:35 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id B812D170C2B8; Thu, 5 May 2011 23:42:30 +0930 (CST) Date: Thu, 05 May 2011 14:13:00 -0000 From: Alan Modra To: "H.J. Lu" Cc: binutils@sourceware.org Subject: Re: PATCH: PR ld/12730: regression] crash when allocating in a static constructor Message-ID: <20110505141230.GJ7018@bubble.grove.modra.org> Mail-Followup-To: "H.J. Lu" , binutils@sourceware.org References: <20110505051832.GA28229@intel.com> <20110505082721.GG7018@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00066.txt.bz2 On Thu, May 05, 2011 at 06:26:15AM -0700, H.J. Lu wrote: > On Thu, May 5, 2011 at 1:27 AM, Alan Modra wrote: > > On Wed, May 04, 2011 at 10:18:32PM -0700, H.J. Lu wrote: > >> When we put .ctors into .init_array, we have to reverse copy .ctors secton. > >> Otherwise, constructor function may not work with C++ run-time library > >> correctly.  OK for trunk? > > > > What about .dtors?  You have the same problem there.  I suspect, but > > You are right. Here is the updated patch to handle .dtors sections > with the updated testcase. OK for trunk? No. > > haven't verified, that .ctors.* and .dtors.* also need reversing.  If > > that is true then it would be better to do your reversing trick for > > anything going to the .init_array output section that isn't named > > .init_array* and similarly for .fini_array. Are you sure there is no need to reverse .ctors.* and .dtors.*? The reason I recommended testing the output section is that limits section reversal to that particular output section. I will not approve a patch that ignores this recommendation. You also should remove reverse_copy_ctors. That's plain wrong. Consider people linking using a custom (old) script that does not put .ctors into .init_array. > > You also need to reverse any dynamic relocations applying to the > > sections you are reversing. > > It isn't a problem since we apply relocations on the input sections > first and copy relocated input sections to output where I reverse > copy .ctors/.dtors sections if needed. Try compiling your testcase as a PIE or shared lib on a target that uses RELA. I haven't tried it, but I think the dynamic RELATIVE relocs you'll get in .ctors will undo your section reversing. -- Alan Modra Australia Development Lab, IBM