From patchwork Wed Mar 18 23:16:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 451669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BA6591400B7 for ; Thu, 19 Mar 2015 10:17:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=ED/liaFR; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=pWAShK+sDv70OAhvWa17Ln+gx/njCJGIU9uxl8Y5XZ85eJ QWeQWrvfseE8vqZbpOklmMfOODWiGcgx10guzBAEdJXYVfdIi0xkMbCsSAFTbVvS 5kjUq14QLxi0eClomaT7gESZqoWvl/o9wC6D5wc2Aq/KR6HhX1z3Mgvgx1uLo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=F6DnL54J1Gil/l9vYM56tmSsHXI=; b=ED/liaFR52X7+DzTc3IT 11tervx96SXxPUHcFWGn4YlgWa9jLmTRSImvhkkXeP2sL2zvFFPSixpZFWiRw8jJ bapivm+SDbVqYNf56r/dP2c2OEBGaTNyCElwhgnQrq3FdMhjlIeNjvfB24MrSb1p Lf435Yk3xqy3g4b0dXagm84= Received: (qmail 103996 invoked by alias); 18 Mar 2015 23:17:02 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 103981 invoked by uid 89); 18 Mar 2015 23:17:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [PATCH roland/arm] ARM: Fix memcpy & memmove for [ARM_ALWAYS_BX] Message-Id: <20150318231657.DE4582C3B2C@topped-with-meat.com> Date: Wed, 18 Mar 2015 16:16:57 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=duwM4wpIP8cTWxRjndAA:9 a=CjuIK1q_8ugA:10 This was an oversight when I originally modified this code to handle the ARM_ALWAYS_BX and ARM_BX_ALIGN_LOG2 > 2 cases. I'm not sure how I managed to miss it before. This has no effect on existing (Linux) configurations. I've tested the fixed code on arm-nacl (under qemu) and after this there are no test suite failures in string/ (before there were many). OK? Thanks, Roland 2015-03-18 Roland McGrath * sysdeps/arm/memcpy.S [ARM_ALWAYS_BX]: Fix computed-jump calculations to account for alignment padding. * sysdeps/arm/memmove.S: Likewise. --- a/sysdeps/arm/memcpy.S +++ b/sysdeps/arm/memcpy.S @@ -125,7 +125,12 @@ ENTRY(memcpy) push {r10} cfi_adjust_cfa_offset (4) cfi_rel_offset (r10, 0) - add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) +0: add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) + /* If alignment is not perfect, then there will be some + padding (nop) instructions between this BX and label 6. + The computation above assumed that two instructions + later is exactly the right spot. */ + add r10, #(6f - (0b + PC_OFS)) bx r10 #endif .p2align ARM_BX_ALIGN_LOG2 @@ -156,11 +161,16 @@ ENTRY(memcpy) add pc, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) nop #else - add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) +0: add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) + /* If alignment is not perfect, then there will be some + padding (nop) instructions between this BX and label 6. + The computation above assumed that two instructions + later is exactly the right spot. */ + add r10, #(66f - (0b + PC_OFS)) bx r10 #endif .p2align ARM_BX_ALIGN_LOG2 - nop +66: nop .p2align ARM_BX_ALIGN_LOG2 sfi_breg r0, \ str r3, [\B], #4 --- a/sysdeps/arm/memmove.S +++ b/sysdeps/arm/memmove.S @@ -141,7 +141,12 @@ ENTRY(memmove) push {r10} cfi_adjust_cfa_offset (4) cfi_rel_offset (r10, 0) - add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) +0: add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) + /* If alignment is not perfect, then there will be some + padding (nop) instructions between this BX and label 6. + The computation above assumed that two instructions + later is exactly the right spot. */ + add r10, #(6f - (0b + PC_OFS)) bx r10 #endif .p2align ARM_BX_ALIGN_LOG2 @@ -172,11 +177,16 @@ ENTRY(memmove) add pc, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) nop #else - add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) +0: add r10, pc, ip, lsl #(ARM_BX_ALIGN_LOG2 - 2) + /* If alignment is not perfect, then there will be some + padding (nop) instructions between this BX and label 6. + The computation above assumed that two instructions + later is exactly the right spot. */ + add r10, #(66f - (0b + PC_OFS)) bx r10 #endif .p2align ARM_BX_ALIGN_LOG2 - nop +66: nop .p2align ARM_BX_ALIGN_LOG2 sfi_breg r0, \ str r3, [\B, #-4]!