From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24130 invoked by alias); 5 Jan 2017 14:16:26 -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 24120 invoked by uid 89); 5 Jan 2017 14:16:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*MI:sk:ac3ec52, H*f:sk:ac3ec52, H*i:sk:ac3ec52 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jan 2017 14:16:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0FA9C154D; Thu, 5 Jan 2017 06:16:14 -0800 (PST) Received: from [10.2.206.198] (e104437-lin.cambridge.arm.com [10.2.206.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4ED2A3F318; Thu, 5 Jan 2017 06:16:13 -0800 (PST) Subject: Re: [ARM] Allow MOV/MOV.W to accept all possible immediates To: Szabolcs Nagy References: <27959ba0-3b6f-185d-1c8b-55a28d7e286c@foss.arm.com> <586E23CD.7030903@arm.com> <586E24A6.2020606@arm.com> Cc: Binutils , Rich Felker , Reiner Herrmann From: Jiong Wang Message-ID: <039ff06e-19a5-214f-0b68-feececcea951@foss.arm.com> Date: Thu, 05 Jan 2017 14:16:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00084.txt.bz2 On 05/01/17 13:59, Jiong Wang wrote: > On 05/01/17 10:49, Szabolcs Nagy wrote: >> adding the reporter to cc and rich because it broke musl. >> >> On 05/01/17 10:45, Szabolcs Nagy wrote: >>> On 01/11/16 12:21, Jiong Wang wrote: >>>> Hi, >>>> >>>> AArch32 MOV Rd, #imm should accept all immediates which can be >>>> encoded into >>>> available encoding, A1/A2 for ARM, T1/T2/T3 for Thumb/Thumb2, and >>>> MOV is the >>>> preferred disassembly syntax. See latest ARM Architecture >>>> Reference Manual for >>>> ARMv8-A, section F6.1.108 and for ARMv8-M, section C2.4.89. >>>> >>>> The same for MOV.W under Thumb mode. It should try all possible >>>> 32-bit Thumb >>>> encoding instead of T2 only. >>>> >>>> This patch let MOV/MOV.W accept more immediate formats while >>>> their currently >>>> supported immediate formats are not affected, so there is no >>>> backward compatibility >>>> issue, also this patch haven't touched the disassembler. >>>> >>>> I think this patch brings GAS closer to ARM Architecture >>>> Reference Manual. >>>> >>>> OK for master? >>>> >>>> gas/ >>>> 2016-11-01 Jiong Wang >>>> * config/tc-arm.c (SBIT_SHIFT): New. >>>> (T2_SBIT_SHIFT): Likewise. >>>> (t32_insn_ok): Return TRUE for MOV in ARMv8-M Baseline. >>>> (md_apply_fix): Try UINT16 encoding when ARM/Thumb >>>> modified immediate >>>> encoding failed. >>>> * testsuite/gas/arm/archv6t2-bad.s: New error case. >>>> * testsuite/gas/arm/archv6t2-bad.l: New error match. >>>> * testsuite/gas/arm/archv6t2.s: New testcase. >>>> * testsuite/gas/arm/archv6t2.d: New expected result. >>>> * testsuite/gas/arm/archv8m.s: New testcase >>>> * testsuite/gas/arm/archv8m-base.d: New expected result. >>>> * testsuite/gas/arm/archv8m-main.d: Likewise. >>>> * testsuite/gas/arm/archv8m-main-dsp-1.d: Likewise. >>> this caused >>> >>> $ cat bug.s >>> .syntax unified >>> .text >>> .arch armv7-a >>> mov r3,#1 >>> >>> .arch armv4t >>> .eabi_attribute 6,2 >>> bx lr >>> >>> $ arm-none-linux-gnueabihf-as -mthumb bug.s >>> bug.s: Assembler messages: >>> bug.s:4: Error: invalid constant (1) after fixup >>> >>> previously this worked, but i'm not sure if the mix >>> of .arch directives and .syntax unified is valid here. > > It looks to me the failure is caused by the second ".arch armv4t" > overrides the > first ".arch armv7-a", therefore the arch feature is lowerd to armv4t in > assembler fixup stage. While "mov r3, #1" under thumb mode is only > allowed > with ARMv6T2. > > This patch tightend the check from > > if (fixP->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE > || fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM) > > into: > > if ((fixP->fx_r_type == BFD_RELOC_ARM_T32_IMMEDIATE > && ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6t2)) > || fixP->fx_r_type == BFD_RELOC_ARM_T32_ADD_IMM) > > > thus the sequences in bug.s is not allowed. Does .object_arch works for you? It seems you want the final object arch adjusted. https://sourceware.org/ml/binutils/2006-09/msg00054.html > >