gas should, but doesn't, treat pc-relative stores of form "str <Rt>, <label>" as an error in Thumb-2

Bug #716950 reported by Dave Martin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro Binutils
Fix Released
Low
Unassigned
Linaro GCC
Invalid
Undecided
Unassigned

Bug Description

Environment:
  * Linaro/Ubuntu binutils-arm-linux-gnueabi (2.20.51.20100908-0ubuntu2cross1.50), on x86_64
  * also Upstream CVS 20110211 (--build=x86_64 --host=x86_64 --target=arm-elf-eabi)

In my case, the resulting code fell over with alignment faults at runtime (I suspect the A8 implementation may do the store but doesn't align the PC as would happen for PC-relative loads).

ARMv7 specifies the generated instruction encoding to be UNDEFINED, so we certainly shouldn't generate it in assembly output.

In the following example, note how the first store (to label "d") on line 5 is erroneously allowed, but the explicit pc-relative store on line 6 is correctly rejected.

$ arm-elf-eabi-as -ahlms -o strpc.o strpc.s
strpc.s: Assembler messages:
strpc.s:6: Error: cannot use register index with PC-relative addressing – `str r0,[pc,4]'
ARM GAS strpc.s page 1

1 .syntax unified
2 .arch armv7-a
3
4 .thumb_func
5 ???? 4FF8000C f: str r0, d
6 str r0, [pc, 4]
7
8 ???? 00000000 .space 4
9 .align
10 ???? 00000000 d: .long 0
11
ARM GAS strpc.s page 2

DEFINED SYMBOLS
strpc.s:5 .text:0000000000000000 f
strpc.s:10 .text:0000000000000000 d
.text:0000000000000000 $d
strpc.s:5 .text:0000000000000000 $t
strpc.s:8 .text:0000000000000000 $d
strpc.s:9 .text:0000000000000000 $t
strpc.s:10 .text:0000000000000000 $d
strpc.s:11 .text:0000000000000000 $t
.data:0000000000000000 $d
.bss:0000000000000000 $d
.ARM.attributes:000000000000001f $d

NO UNDEFINED SYMBOLS

$ cat strpc.s
.syntax unified
.arch armv7-a

.thumb_func
f: str r0, d
str r0, [pc, 4]

.space 4
.align
d: .long 0

Changed in gcc-linaro:
status: New → Invalid
Changed in binutils-linaro:
status: New → Triaged
Changed in binutils-linaro:
importance: Undecided → Low
Changed in binutils-linaro:
status: Triaged → Fix Committed
Changed in binutils-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.