From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24010 invoked by alias); 16 Mar 2005 14:56:25 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 23341 invoked from network); 16 Mar 2005 14:56:06 -0000 Received: from unknown (HELO cam-admin0.cambridge.arm.com) (193.131.176.58) by sourceware.org with SMTP; 16 Mar 2005 14:56:06 -0000 Received: from pc960.cambridge.arm.com (pc960.cambridge.arm.com [10.1.205.4]) by cam-admin0.cambridge.arm.com (8.12.10/8.12.10) with ESMTP id j2GEtM4G003155; Wed, 16 Mar 2005 14:55:22 GMT Received: from pc960.cambridge.arm.com (localhost.localdomain [127.0.0.1]) by pc960.cambridge.arm.com (8.12.8/8.12.8) with ESMTP id j2GEtWIF021813; Wed, 16 Mar 2005 14:55:32 GMT Received: (from rearnsha@localhost) by pc960.cambridge.arm.com (8.12.8/8.12.8/Submit) id j2GEtWJp021811; Wed, 16 Mar 2005 14:55:32 GMT X-Authentication-Warning: pc960.cambridge.arm.com: rearnsha set sender to rearnsha@gcc.gnu.org using -f Subject: Re: [PATCH] Fix thumb calls via PLT on ARM/SymbianOS From: Richard Earnshaw To: Julian Brown Cc: Daniel Jacobowitz , binutils@sources.redhat.com In-Reply-To: <42384770.8030104@codesourcery.com> References: <42383FF3.4080604@codesourcery.com> <1110982992.19581.35.camel@pc960.cambridge.arm.com> <20050316144218.GA27174@nevyn.them.org> <42384770.8030104@codesourcery.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: GNU Message-Id: <1110984932.19581.44.camel@pc960.cambridge.arm.com> Mime-Version: 1.0 Date: Wed, 16 Mar 2005 16:29:00 -0000 X-SW-Source: 2005-03/txt/msg00444.txt.bz2 On Wed, 2005-03-16 at 14:49, Julian Brown wrote: > Daniel Jacobowitz wrote: > > On Wed, Mar 16, 2005 at 02:23:12PM +0000, Richard Earnshaw wrote: > > > >>On Wed, 2005-03-16 at 14:17, Julian Brown wrote: > >> > >>>Hi, > >>> > >>>This patch fixes calls made from thumb mode via the PLT on SymbianOS. > >>>PLT entries are written in ARM mode, but previously they were being > >>>called in thumb mode, with their address incorrectly offset by -4 > >>>(PLT_THUMB_STUB_SIZE). > >>> > >>>Now, the target address has been corrected and the thumb BL instruction > >>>is rewritten as BLX to perform the mode switch before attempting to > >>>execute the PLT entry. (BLX is an armv5t instruction, but as SymbianOS > >>>is only targeted at armv5t+, this should always be OK.) > >>> > >>>The hardwired "4" for the thumb stub size on non-SymbianOS targets has > >>>also been rewritten as PLT_THUMB_STUB_SIZE. > >>> > >>>OK to apply? > >> > >>This sounds like a hack. I'd much rather a generic solution were found > >>(and which permitted the blx optimization if available). > > > > > > The SymbianOS bits sound generally right to me. The fact that the -4 > > bias is currently included is just a bug; that's from the code to > > generate a Thumb header on PLT entries, which is already disabled > > for SymbianOS. > > > > OTOH, it may be missing some error checks - what if it's _not_ a BL? > > Could we reach here? > > I assumed not: this is an R_ARM_THM_PC22, alias R_ARM_THM_CALL > relocation. Can that sensibly point at anything else? > Ah! Yep, that can only apply to a thumb BL instruction. > Would it be better to add a --target-arch (or something) flag to > binutils at this point? That would tidy up a previous patch of mine, > too. I don't know if any other targets have, or need, such an option. Yep, I think that would be a good idea. Ideally we'd want a linker command-line option as well, but a configuration option would be a good first step. R.