I have the following bit of assembly: .syntax unified .cpu cortex-m4 .thumb .section .text orr r1, #12800 orr r1, #12801 I invoke the GNU assembler as follows: arm-none-eabi-gcc -g -Wall -c bla.s The assembler issues no warnings, but the output, when inspected with objdump, looks as follows: bla.o: file format elf32-littlearm Disassembly of section .text: 00000000 <.text>: 0: f441 5148 orr.w r1, r1, #12800 ; 0x3200 4: f243 2101 movw r1, #12801 ; 0x3201 The second orr instruction, which should've produced an error since the constant #12801 cannot be encoded as an immediate, was silently changed into a mov instruction instead. The exact version of the assembler is: GNU assembler version 2.29.51 (arm-none-eabi) using BFD version (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 2.29.51.20171128 I'm running OSX: Darwin trumposaurus.local 15.6.0 Darwin Kernel Version 15.6.0: Sun Jun 4 21:43:07 PDT 2017; root:xnu-3248.70.3~1/RELEASE_X86_64 x86_64
I highly suspect commit bada434212 to be the problem, in particular the fragment starting at tc-arm.c:23596.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db7bf1058d28b2b5e931c60435a13f6db15df6af commit db7bf1058d28b2b5e931c60435a13f6db15df6af Author: Nick Clifton <nickc@redhat.com> Date: Tue Feb 13 16:50:04 2018 +0000 Fix ARm assembler so that it rejects invalid immediate values for the Thumb ORR instruction. PR 22773 * config/tc-arm.c (md_apply_fix): Test Rn field of Thumb ORR instruction before assuming that it is a MOV instruction. * testsuite/gas/arm/pr22773.s: New test. * testsuite/gas/arm/pr22773.d: New test driver. * testsuite/gas/arm/pr22773.l: New expected output.
Hi Jeroen, Thanks for reporting this bug, and sorry for the delay in fixing it. The problem was indeed the code that you identified. It was failing to check that the ORR instruction was actually a MOV instruction before it altered the encoding. I have checked in a small patch to fix this, added your test as a new testcase in the assembler testsuite and checked the result in to the mainstream sources. Cheers Nick
Hi Nick, thanks for the fix!
The binutils-2_30-branch branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=763e359efaba5cc088604e3f3e1dda40fda06831 commit 763e359efaba5cc088604e3f3e1dda40fda06831 Author: Nick Clifton <nickc@redhat.com> Date: Thu Mar 29 12:31:04 2018 +0100 Import patch from the mainline that fixes the ARM assembler's parsing of an illegal ORR instruction. PR 22773 * config/tc-arm.c (md_apply_fix): Test Rn field of Thumb ORR instruction before assuming that it is a MOV instruction. * testsuite/gas/arm/pr22773.s: New test. * testsuite/gas/arm/pr22773.d: New test driver. * testsuite/gas/arm/pr22773.l: New expected output.