aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2019-09-24 14:46:17 +0100
committerTamar Christina <tamar.christina@arm.com>2019-09-24 15:00:41 +0100
commite8f8842d90abe5eafa8c32f08fbc3a747a45747c (patch)
tree880995ce4582f8054790b4b962f9b7a0b705bda6 /gas/testsuite
parent352f6bc3e5b23e76d8e6f56fb7db4e57d8f5d5bd (diff)
downloadgdb-e8f8842d90abe5eafa8c32f08fbc3a747a45747c.zip
gdb-e8f8842d90abe5eafa8c32f08fbc3a747a45747c.tar.gz
gdb-e8f8842d90abe5eafa8c32f08fbc3a747a45747c.tar.bz2
Arm: Fix out of range conditional branch (PR/24991)
The fix for PR12848 introduced an off by one error in the mask, this corrected the negative overflows but not the positive overflows. As a result the conditional branch instructions accepted a too wide positive immediate which resulted in it corrupting the instruction during encoding. The relocation I believe has been incorrectly named, to be consistent with the other relocations it should have been named BRANCH21 which is why the masks for it are confusing. I've replaced the masks with a function out_of_range_p which should make it harder to make such mistakes. The mask for BL/BLX on Armv6t+ is also wrong, the extended range is 25-bits and so the mask should be checking for 24-bits for positive overflow. gas/ChangeLog: PR gas/24991 * config/tc-arm.c (out_of_range_p): New. (md_apply_fix): Use it in BFD_RELOC_THUMB_PCREL_BRANCH9, BFD_RELOC_THUMB_PCREL_BRANCH12, BFD_RELOC_THUMB_PCREL_BRANCH20, BFD_RELOC_THUMB_PCREL_BRANCH23, BFD_RELOC_THUMB_PCREL_BRANCH25 * testsuite/gas/arm/pr24991.d: New test. * testsuite/gas/arm/pr24991.l: New test. * testsuite/gas/arm/pr24991.s: New test.
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/arm/pr24991.d4
-rw-r--r--gas/testsuite/gas/arm/pr24991.l2
-rw-r--r--gas/testsuite/gas/arm/pr24991.s5
3 files changed, 11 insertions, 0 deletions
diff --git a/gas/testsuite/gas/arm/pr24991.d b/gas/testsuite/gas/arm/pr24991.d
new file mode 100644
index 0000000..2acca2d
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr24991.d
@@ -0,0 +1,4 @@
+#as: -march=armv7-a
+#source: pr24991.s
+#error_output: pr24991.l
+
diff --git a/gas/testsuite/gas/arm/pr24991.l b/gas/testsuite/gas/arm/pr24991.l
new file mode 100644
index 0000000..4fc5875
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr24991.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:4: Error: conditional branch out of range
diff --git a/gas/testsuite/gas/arm/pr24991.s b/gas/testsuite/gas/arm/pr24991.s
new file mode 100644
index 0000000..27f8daf
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr24991.s
@@ -0,0 +1,5 @@
+ .arch armv7-a
+ .syntax unified
+ .thumb
+ beq .+ 0x124f80
+