[ARM] Allow MOV/MOV.W to accept all possible immediates

Jan Beulich JBeulich@suse.com
Thu Jan 5 14:22:00 GMT 2017


>>> On 05.01.17 at 14:59, <jiong.wang@foss.arm.com> wrote:
> On 05/01/17 10:49, Szabolcs Nagy wrote:
>> On 05/01/17 10:45, Szabolcs Nagy wrote:
>>> $ 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.

Suggests pretty clearly that the fixup should record the arch in
use at the time it is being created.

Jan



More information about the Binutils mailing list