From patchwork Tue Aug 29 10:10:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Cowgill X-Patchwork-Id: 4875 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp3017263jao; Tue, 29 Aug 2017 03:16:50 -0700 (PDT) X-Received: by 10.223.185.39 with SMTP id k36mr2112378wrf.251.1504001810839; Tue, 29 Aug 2017 03:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504001810; cv=none; d=google.com; s=arc-20160816; b=xCFHtpmwO+l3TPueUiItMGPNQhbpiT4mWQcHSeJ/3G3sDfvS1l3+RuLqHpN7SxRDvF PoMFUniHhumVcRnSuTvpw2e3Zer9lDc+vm2N0+kIA7LwZKFFwNmNy5aHdFPN8NA8UCKd LEqPOuJ60Ld/yYlrZrxwDK6P8AW+0nutsAdPxk4FBy4xhMNVdYhV/YzLcJGyMrXvf4qQ 64zcnC/Vfgl8coQqZOl1Ic7/TyMQcZYtAMfMTDerIxK4RJRUpqxhmBB6Jy7C1LKDseAa ygnsAaxPjDRLLQZZiTbEqTTmpY4Yql8chDiH12IJKRND3jxCYiXdDksoRvHs2i5rhW16 F/uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:in-reply-to:references :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=peIaB7Hnj+9HS1of/ZNCED0m6qCwbX3tTsMScj7mdm4=; b=NVzOxy5gyqU/uSioxNEFpLKJfhDSIB5n0Bb3Ob4B2kuDaqwghj+hutxOezxpk7lRBL ihoDoRURR5+eQIHG8gl2SHQ/CEZY1hGpFanc+EGnghkWuVNXn8JbWBQ7apIQv+mzz4Hm isa6bL2IonL8DQq81hmP640PTOAJ70yaxCeyGIIomfPXOAfO4YgH8VUQZhHnBPZwfVW+ 89aS5qB8BvBVN5BXzw12NUjzWKeC1lnfA+UTntnsJFuVEYnIUrHB5p4MQ+/aZUcaebF7 vjuFxbB5GF8zadir9sem05/Yxmjt1S98TOgUWsbwtK/u8oIKywnCUG+dJr3K2GH6qo7c 9ZKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jcowgill.uk header.s=melkor-201705 header.b=NKba6Iy8; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e131si1850451wme.109.2017.08.29.03.16.43; Tue, 29 Aug 2017 03:16:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@jcowgill.uk header.s=melkor-201705 header.b=NKba6Iy8; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A781B68A132; Tue, 29 Aug 2017 13:16:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from melkor.jcowgill.uk (melkor.jcowgill.uk [185.145.46.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2859C689DEA for ; Tue, 29 Aug 2017 13:16:34 +0300 (EEST) Received: by melkor.jcowgill.uk (Postfix, from userid 1000) id 8435F2CF; Tue, 29 Aug 2017 11:16:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jcowgill.uk; s=melkor-201705; t=1504001793; bh=PAjm84HGiWqsESimBwp5qWDCa2HsSin2pUyGoX1jgoo=; h=From:To:Date:Subject:Message-Id:From; b=NKba6Iy8cIn0Zdy6rhsU2jO9Ifa5Nd+5ZJzNaHcEhsYfjE/vRddOKsqxzrGpyJQne qmnSqbjlXqzirUpJYOeJ/DFXQQTf85w+IXg7FCr9hF/ORL/EKbjG9E/6ZnOWpOBQW/ pc8Q6hfTUpO+qu0P9FP85M/+iFkplAMoUcCYLg/C2D8zisg9nIFjpddPojqZX/GtHk OsBI0GBKTogscZGko1zeBY+QoP+heHuQPmg7Llfw0cirpDadzulSW994Fm4NPnfTn0 80AYzIP7A1vQ1hvNvy6jFoOPJNtBoky6fPr0qv8qulNc+1MNwhez+pc+2LY7Pwf1Pk 7/MfBBIwlwzUg== From: James Cowgill To: ffmpeg-devel@ffmpeg.org References: <20170828232815.8BEFF370@melkor.jcowgill.uk> In-Reply-To: <20170828232815.8BEFF370@melkor.jcowgill.uk> Date: Tue, 29 Aug 2017 11:10:14 +0100 Message-Id: <20170829101633.8435F2CF@melkor.jcowgill.uk> Subject: [FFmpeg-devel] [PATCH v2] avcodec/arm: Fix SIGBUS on ARM when compiled with binutils 2.29 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In binutils 2.29, the behavior of the ADR instruction changed so that 1 is added to the address of a Thumb function (previously nothing was added). This allows the loaded address to be passed to a BLX instruction and the correct mode change will occur. So that the behavior matches in binutils 2.29 and pre-2.29, use .eqv to pre-calculate the function address without the automatic +1 fixup. Then use these new symbols as the function addresses to be loaded. Fixes ticket 6571. Related binutils bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21458 Signed-off-by: James Cowgill --- v2: Forgot to include the "avcodec/arm" commit message prefix. libavcodec/arm/h264idct_neon.S | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S index 4f68bdb9f5..04b1ea583b 100644 --- a/libavcodec/arm/h264idct_neon.S +++ b/libavcodec/arm/h264idct_neon.S @@ -20,6 +20,18 @@ #include "libavutil/arm/asm.S" +# In binutils 2.29, the behavior of the ADR instruction changed so that 1 is +# added to the address of a Thumb function (previously nothing was added). +# +# These .eqv are used to pre-calculate the correct address with +CONFIG_THUMB so +# that ADR will work with both old and new versions binutils. +# +# See: https://sourceware.org/bugzilla/show_bug.cgi?id=21458 +.eqv eqv_ff_h264_idct_add_neon, X(ff_h264_idct_add_neon) + CONFIG_THUMB +.eqv eqv_ff_h264_idct_dc_add_neon, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB +.eqv eqv_ff_h264_idct8_add_neon, X(ff_h264_idct8_add_neon) + CONFIG_THUMB +.eqv eqv_ff_h264_idct8_dc_add_neon, X(ff_h264_idct8_dc_add_neon) + CONFIG_THUMB + function ff_h264_idct_add_neon, export=1 vld1.64 {d0-d3}, [r1,:128] vmov.i16 q15, #0 @@ -113,8 +125,8 @@ function ff_h264_idct_add16_neon, export=1 movne lr, #0 cmp lr, #0 ite ne - adrne lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB - adreq lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB + adrne lr, eqv_ff_h264_idct_dc_add_neon + adreq lr, eqv_ff_h264_idct_add_neon blx lr 2: subs ip, ip, #1 add r1, r1, #32 @@ -138,8 +150,8 @@ function ff_h264_idct_add16intra_neon, export=1 cmp r8, #0 ldrsh r8, [r1] iteet ne - adrne lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB - adreq lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB + adrne lr, eqv_ff_h264_idct_add_neon + adreq lr, eqv_ff_h264_idct_dc_add_neon cmpeq r8, #0 blxne lr subs ip, ip, #1 @@ -166,8 +178,8 @@ function ff_h264_idct_add8_neon, export=1 cmp r8, #0 ldrsh r8, [r1] iteet ne - adrne lr, X(ff_h264_idct_add_neon) + CONFIG_THUMB - adreq lr, X(ff_h264_idct_dc_add_neon) + CONFIG_THUMB + adrne lr, eqv_ff_h264_idct_add_neon + adreq lr, eqv_ff_h264_idct_dc_add_neon cmpeq r8, #0 blxne lr add r12, r12, #1 @@ -388,8 +400,8 @@ function ff_h264_idct8_add4_neon, export=1 movne lr, #0 cmp lr, #0 ite ne - adrne lr, X(ff_h264_idct8_dc_add_neon) + CONFIG_THUMB - adreq lr, X(ff_h264_idct8_add_neon) + CONFIG_THUMB + adrne lr, eqv_ff_h264_idct8_dc_add_neon + adreq lr, eqv_ff_h264_idct8_add_neon blx lr 2: subs r12, r12, #4 add r1, r1, #128