From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2242 invoked by alias); 20 Apr 2006 18:49:27 -0000 Received: (qmail 2229 invoked by uid 22791); 20 Apr 2006 18:49:26 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Thu, 20 Apr 2006 18:49:24 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FWeDR-0005bi-JB; Thu, 20 Apr 2006 14:49:21 -0400 Date: Fri, 21 Apr 2006 03:23:00 -0000 From: Daniel Jacobowitz To: Paul Brook Cc: binutils@sourceware.org Subject: Re: [patch] R_ARM_REL32 and Thumb functions. Message-ID: <20060420184921.GA21343@nevyn.them.org> Mail-Followup-To: Paul Brook , binutils@sourceware.org References: <200604201929.50393.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200604201929.50393.paul@codesourcery.com> User-Agent: Mutt/1.5.8i 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-04/txt/msg00294.txt.bz2 On Thu, Apr 20, 2006 at 07:29:49PM +0100, Paul Brook wrote: > The attached patch makes the R_ARM_REL32 relocation set the low bit of the > value when the relocated symbol is a Thumb function, as required by the ARM > EABI. > > I don't know if the current behavior is considered a bug or a feature for > pre-EABI objects. For now I'm assuming bug, and making the change > unconditionally. I can preserver the old behavior if anything depends on it. > > A slight complication is that gas will try and fold relative expressions at > assembly time. This folding is done in generic code, so gets the value wrong. > e.g. > > .thumb_func > foo: > .word foo - . > > Will be folded to zero by gas/expr.c:expr. I've [ab]used md_optimize_expr to > prevent this happening. > > Initially I disabled the folding if either symbol was a Thumb function. > However this ends up breaking the explicit cfi directives in libgcc, so I've > only disabled the folding when the first symbol is a Thumb function. Wow, this is nasty! I can understand why Richard, and presumably the ABI, wants this to happen: ldr ip, 1f 2: add ip, pc, ip bx ip 1: .word foo - . - (2b - .) But I'd be mighty confused if, say, some code tried to copy itself from one location to another and expected "foo - ." to describe the number of bytes to be copied. And now "foo - ." and ". - foo" are assymetric. -- Daniel Jacobowitz CodeSourcery