From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28703 invoked by alias); 23 May 2006 05:27:17 -0000 Received: (qmail 28694 invoked by uid 22791); 23 May 2006 05:27:17 -0000 X-Spam-Check-By: sourceware.org Received: from CPE-144-136-172-108.sa.bigpond.net.au (HELO grove.modra.org) (144.136.172.108) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 23 May 2006 05:27:15 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id C96B71E117E; Tue, 23 May 2006 14:57:12 +0930 (CST) Date: Tue, 23 May 2006 09:35:00 -0000 From: Alan Modra To: "Peter S. Mazinger" Cc: binutils@sourceware.org Subject: Re: weak and strong aliases for global data fail Message-ID: <20060523052712.GC12196@bubble.grove.modra.org> Mail-Followup-To: "Peter S. Mazinger" , binutils@sourceware.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00399.txt.bz2 On Mon, May 22, 2006 at 10:38:56PM +0200, Peter S. Mazinger wrote: > On Wed, 17 May 2006, Peter S. Mazinger wrote: > > Could anyone tell me if this is a binutils bug (tested 2.16.1/2.16.92) or > I should send it to the gcc list (tested with 3.4.6). It seems to me that > it is rather an ld bug. > > Thanks, Peter > > > Hello! > > > > Attached tests show a case, when a final binary is OK if > > compiled w/ -fPIC (or -fPIE, it does not have to be ET_DYN, but can be), > > else it fails if using aliases (both weak and strong) for global data. > > > > Sorry for the "big" test cases, I couldn't make them smaller. It's a user bug. When the linker needs to generate a copy reloc, eg. as it does for x86 non-PIC code, for a variable like "optind_test" in your main app, then space is allocated in your main app and initialised from the shared object. The main app uses this location for references to "optind_test", as do references from within the shared lib. However, your shared lib is not referencing "optind_test" but an alias stored at a different location (in the shared lib). With PIC code the linker can generally dispense with the copy reloc, so both the main app and the shared lib use the same location. -- Alan Modra IBM OzLabs - Linux Technology Centre