From patchwork Mon Aug 28 23:18:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Cowgill X-Patchwork-Id: 4867 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp2635661jao; Mon, 28 Aug 2017 16:28:25 -0700 (PDT) X-Received: by 10.28.74.153 with SMTP id n25mr15179wmi.128.1503962905811; Mon, 28 Aug 2017 16:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503962905; cv=none; d=google.com; s=arc-20160816; b=sxgH/NfoY3MRq+7LszWwMDIHNYG6nQ+YCxf3Rf3wf1Wpe28yNqZSDfAy9mNnWAWdRa sl1o7seb/5xu0j1MUCSifn39j8CkRKoosUCy6ft9xP4Fzbr8kocS0ZveZ64c4jo4liCt sBSf4beufuYGUHoZqEkfgcRUoaq89QnRVL22fy3CPxlhuAO41M6mXdzW6kmOtUABVxdH lkqw0hXf9Cyu/XILxFMcv9W9G/xPWKT4yXinm67TIybRtdvJkuW84yORnXvcAsRTa2c2 Ed43MAFymMlehmEMn8gTKMmdPOIrVFZC7szxWUNwkW1s9ZX4NFNxN4F/Hhvyc1sKsZA4 kZjQ== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=bnxsOHnw0HM6eLBTfh5AakbtD/kSnOmqhSGDWaDkxq0=; b=s0SVP5F6THAKWTU1d3bgVVlIEu/IYfPDRHxwtVqUu55DRnz2cOTEkb18GLM/R2Wowo m9/5T9SX8YH7JC14R6nBemr/a7/SOal1uMhSny+I9626E8Hqnit0IaOvk7t29VG3GR57 AGR7cOJXHoph7dZ8Q/eG9qmYIp8QsjBdWmdlAptD2OwKbow7klrJiHCv05D5v+6dk5GJ hYELFA6zORQkFhFKSSoESWz9pkZWNbQutRxlVRUAtBqi+DVPgBiNF59AxEF/QLubJn65 4YARz1cTn6cDhJN1zw7qJIbbZlY+WJI1T60oiKzRhs2V7P0Fgcml4pcYQCS1HvrerJ8r sIBA== 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=H9FeegoY; 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 a12si1176444wrh.216.2017.08.28.16.28.25; Mon, 28 Aug 2017 16:28:25 -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=H9FeegoY; 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 32A2068A03A; Tue, 29 Aug 2017 02:28:12 +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 57242689F5D for ; Tue, 29 Aug 2017 02:28:06 +0300 (EEST) Received: by melkor.jcowgill.uk (Postfix, from userid 1000) id 8BEFF370; Tue, 29 Aug 2017 00:28:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jcowgill.uk; s=melkor-201705; t=1503962895; bh=kAYzT9wsAFFy8mV19JgnEE8zbTMSEndPptkSB99ffQY=; h=From:To:Cc:Date:Subject:Message-Id:From; b=H9FeegoYMsaY5DI2x2sQqRDbkNfD0MQlxtvSloNw3RztnuN0vs+xZdl33UcGVPpb9 6+iN9lSvFTYgoMVmwL3E/UBsOBOhJvdxcghLNsQ8RmtQhOb8IMDEiG4C8k6AcZuMVA +8RMZVIdFKV1NB5l40IMjyqVAuEGS0GRBW326uhoCHubvjPWyx+b+7IMJzSn7KGVZ0 cW0ayu3U8/SUqcJzF6GDSe36DOBgGqd00MwJJNuxjnS8N+rrxsuV80fXkwYcS8w+Pb jaU8nxJ9R63Tn4AEatk9ojFpVNOcc05m2g9lISqIHMTntFWJ6T8jpToD9OVSL0u4y1 dzmvdXwoBzpgA== From: James Cowgill To: ffmpeg-devel@ffmpeg.org Date: Tue, 29 Aug 2017 00:18:52 +0100 Message-Id: <20170828232815.8BEFF370@melkor.jcowgill.uk> Subject: [FFmpeg-devel] [PATCH] 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 Cc: James Cowgill 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. See: https://sourceware.org/bugzilla/show_bug.cgi?id=21458 Fixes ticket 6571. Signed-off-by: James Cowgill --- 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