From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6701 invoked by alias); 6 Jun 2014 12:49:06 -0000 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 Received: (qmail 6690 invoked by uid 89); 6 Jun 2014 12:49:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.0 required=5.0 tests=AWL,BAYES_50,FOREIGN_BODY,NORMAL_HTTP_TO_IP,RDNS_DYNAMIC,T_FILL_THIS_FORM_SHORT autolearn=no version=3.3.2 X-HELO: mail.embedded-brains.de Received: from host-82-135-62-35.customer.m-online.net (HELO mail.embedded-brains.de) (82.135.62.35) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jun 2014 12:49:04 +0000 Received: by mail.embedded-brains.de (Postfix, from userid 65534) id C2601652CFC; Fri, 6 Jun 2014 14:49:01 +0200 (CEST) Received: from [192.168.100.11] (unknown [192.168.100.11]) by mail.embedded-brains.de (Postfix) with ESMTP id 2C3D8652CF6 for ; Fri, 6 Jun 2014 14:49:00 +0200 (CEST) Message-ID: <5391B8B7.8030908@embedded-brains.de> Date: Fri, 06 Jun 2014 12:49:00 -0000 From: Sebastian Huber User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: binutils@sourceware.org Subject: Re: 32-bit PowerPC sdata linker problem References: <53918356.3040102@embedded-brains.de> <20140606105420.GH5592@bubble.grove.modra.org> <5391A4BF.2030308@embedded-brains.de> <5391A6A4.6050708@embedded-brains.de> <20140606121531.GI5592@bubble.grove.modra.org> In-Reply-To: <20140606121531.GI5592@bubble.grove.modra.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00065.txt.bz2 On 2014-06-06 14:15, Alan Modra wrote: > On Fri, Jun 06, 2014 at 01:31:48PM +0200, Sebastian Huber wrote: >> >On 2014-06-06 13:23, Sebastian Huber wrote: >>> > >Ok, so this "cmplwi cr0, rX, ppc_exc_lock_std@sdarel" is illegal, since >>> > >ppc_exc_lock_std@sdarel is signed and the immediate is unsigned 16-bit? The >>> > >assembler doesn't issue a warning about this. >>> > > >>> > >Exists there a way to rescue this cmplwi hack without relaxing the overflow >>> > >checks? >> > >> >Hm, sorry, it was surprisingly simple. This works: >> > >> >"cmplwi cr0, rX, ppc_exc_lock_std@sdarel@l" >> > >> >I was not aware that you can add several @ in a row. > That is the wrong thing to use here. sdarel@l translates to a VLE > reloc which applies to a split 16-bit field in VLE insns. Oh, yes. This is not what I want. > > You want > cmpwi cr0, rX, ppc_exc_lock_std@sdarel > to properly compare a 16-bit signed number from sym@sdarel. > > Note that the assembler does error if you write something like > cmplwi 3,-30000 > or > cmpwi 3,40000 > so what the linker is now doing is extending this behaviour to link > time. I actually need only the lower 16-bit of sym@sdarel here. The code reads an opcode on a certain address and tests if the opcode is equal to "stw r1, ppc_exc_lock_std@sdarel(r13)". /* ***************************************************************************** * MACRO: TEST_1ST_OPCODE_crit ***************************************************************************** * * USES: REG, cr0 * ON EXIT: REG available (contains *pc - STW_R1_R13(0)), * return value in cr0. * * test opcode interrupted by critical (asynchronous) exception; set CR_LOCK if * * *SRR0 == 'stw r1, ppc_exc_lock_std@sdarel(r13)' * */ .macro TEST_1ST_OPCODE_crit _REG lwz \_REG, SRR0_FRAME_OFFSET(FRAME_REGISTER) lwz \_REG, 0(\_REG) /* opcode now in REG */ /* subtract upper 16bits of 'stw r1, 0(r13)' instruction */ subis \_REG, \_REG, STW_R1_R13(0)@h /* * if what's left compares against the 'ppc_exc_lock_std@sdarel' * address offset then we have a match... */ cmplwi cr0, \_REG, ppc_exc_lock_std@sdarel .endm I guess, I have to rewrite this a bit. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.