From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3216 invoked by alias); 22 Jan 2011 15:08:56 -0000 Received: (qmail 3202 invoked by uid 22791); 22 Jan 2011 15:08:55 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SARE_RECV_FREESERVE X-Spam-Check-By: sourceware.org Received: from smtp5.freeserve.com (HELO smtp6.freeserve.com) (193.252.22.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 22 Jan 2011 15:08:41 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf3537.me.freeserve.com (SMTP Server) with ESMTP id 6A0E11C00085; Sat, 22 Jan 2011 16:08:38 +0100 (CET) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf3537.me.freeserve.com (SMTP Server) with ESMTP id 5ABC61C00087; Sat, 22 Jan 2011 16:08:38 +0100 (CET) Received: from barnowl.buzzard.freeserve.co.uk (unknown [95.148.210.167]) by mwinf3537.me.freeserve.com (SMTP Server) with ESMTP id 35B6D1C00085; Sat, 22 Jan 2011 16:08:38 +0100 (CET) Received: from [192.168.2.11] (unknown [192.168.2.11]) by barnowl.buzzard.freeserve.co.uk (Postfix) with ESMTP id 92337C800ED; Sat, 22 Jan 2011 15:07:10 +0000 (GMT) Message-ID: <4D3AF29E.3020708@buzzard.freeserve.co.uk> Date: Sat, 22 Jan 2011 23:44:00 -0000 From: Richard Earnshaw User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org, julian@codesourcery.com Subject: Re: [patch] Fix PR tdep/12352: Handle str pc, [Rd, #imm] in displaced stepping References: <4D1A1343.8020204@codesourcery.com> In-Reply-To: <4D1A1343.8020204@codesourcery.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00452.txt.bz2 On 28/12/10 16:41, Yao Qi wrote: > When I read arm-tdep.c:copy_ldr_str_ldrb_strb, I feel pretty hard to > understand two lines of code, > > dsc->modinsn[0] = 0xe58ff014; /* str pc, [pc, #20]. */ > dsc->modinsn[1] = 0xe59f4010; /* ldr r4, [pc, #16]. */ Hmm, looks like a rather convoluted way of moving the PC into R4. Julian, I think this patch was yours... can you remember why "MOV R4, PC" wasn't sufficient? > > Shall program get SIGSEGV when executing `str pc, [pc, #20]' during > displaced stepping? A simple test case confirmed my guess, which is > included in arm-disp-step.S in this patch. > > If it is a bug here, this patch is to address it. These two lines of > code is to compute the offset of `str pc'. In this patch, we can do > this in a different way, > > str pc, [sp, #-4] > ldr r4, [sp, #-4] > > OK for mainline and 7.2 branch? > No, code must not write below the stack -- the value can get corrupted if an interrupt occurs. (I'm not sure if that's possible in this specific case as the debugger ought to be in control; but it's bad practice to violate the ABI in this way). R.