aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2019-02-01 17:42:54 +0100
committerJohn Darrington <john@darrington.wattle.id.au>2019-02-01 18:08:06 +0100
commit91bae99160e9d81cfe340b937f9613d43dc90293 (patch)
treeea4ee1c0eb6208868c56ddf82965fdfbcf1a0887
parent1d4d86699fcc9641c1f4dfb3a44a1588353c2137 (diff)
downloadgdb-91bae99160e9d81cfe340b937f9613d43dc90293.zip
gdb-91bae99160e9d81cfe340b937f9613d43dc90293.tar.gz
gdb-91bae99160e9d81cfe340b937f9613d43dc90293.tar.bz2
S12Z: GAS: Fix incorrect range test for 16-bit PC relative offsets.
The limits for PC relative offsets were incorrect. This change fixes them and adds some tests. gas/ * config/tc-s12z.c (md_apply_fix): Fix incorrect limits. * testsuite/gas/s12z/pc-rel-bad.d: New file. * testsuite/gas/s12z/pc-rel-bad.l: New file. * testsuite/gas/s12z/pc-rel-bad.s: New file. * testsuite/gas/s12z/pc-rel-good.d: New file. * testsuite/gas/s12z/pc-rel-good.s: New file. * testsuite/gas/s12z/s12z.exp: Add them.
-rw-r--r--gas/ChangeLog10
-rw-r--r--gas/config/tc-s12z.c2
-rw-r--r--gas/testsuite/gas/s12z/pc-rel-bad.d9
-rw-r--r--gas/testsuite/gas/s12z/pc-rel-bad.l3
-rw-r--r--gas/testsuite/gas/s12z/pc-rel-bad.s8
-rw-r--r--gas/testsuite/gas/s12z/pc-rel-good.d24
-rw-r--r--gas/testsuite/gas/s12z/pc-rel-good.s6
-rw-r--r--gas/testsuite/gas/s12z/s12z.exp2
8 files changed, 63 insertions, 1 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index e168d72..a02430d 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,15 @@
2019-01-31 John Darrington <john@darrington.wattle.id.au>
+ * config/tc-s12z.c (md_apply_fix): Fix incorrect limits.
+ * testsuite/gas/s12z/pc-rel-bad.d: New file.
+ * testsuite/gas/s12z/pc-rel-bad.l: New file.
+ * testsuite/gas/s12z/pc-rel-bad.s: New file.
+ * testsuite/gas/s12z/pc-rel-good.d: New file.
+ * testsuite/gas/s12z/pc-rel-good.s: New file.
+ * testsuite/gas/s12z/s12z.exp: Add them.
+
+2019-01-31 John Darrington <john@darrington.wattle.id.au>
+
* config/tc-s12z.c (tfr): Emit warning if operands are the same.
* testsuite/gas/s12z/exg.d: New test case.
* testsuite/gas/s12z/exg.l: New file.
diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index a013149..8b56b68 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -3853,7 +3853,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
bfd_putb32 ((bfd_vma) value, (unsigned char *) where);
break;
case BFD_RELOC_16_PCREL:
- if (value < -0x8000 || value > 0x7FFF)
+ if (value < -0x4000 || value > 0x3FFF)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("Value out of 16-bit range."));
diff --git a/gas/testsuite/gas/s12z/pc-rel-bad.d b/gas/testsuite/gas/s12z/pc-rel-bad.d
new file mode 100644
index 0000000..ae01a7f
--- /dev/null
+++ b/gas/testsuite/gas/s12z/pc-rel-bad.d
@@ -0,0 +1,9 @@
+#objdump: -d -r -t
+#name: PC relative branches which are out of range.
+#source: pc-rel-bad.s
+#error_output: pc-rel-bad.l
+
+.*: file format elf32-s12z
+
+
+Disassembly of section .text:
diff --git a/gas/testsuite/gas/s12z/pc-rel-bad.l b/gas/testsuite/gas/s12z/pc-rel-bad.l
new file mode 100644
index 0000000..e3d63c3
--- /dev/null
+++ b/gas/testsuite/gas/s12z/pc-rel-bad.l
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:4: Error: Value out of 16-bit range.
+.*:8: Error: Value out of 16-bit range.
diff --git a/gas/testsuite/gas/s12z/pc-rel-bad.s b/gas/testsuite/gas/s12z/pc-rel-bad.s
new file mode 100644
index 0000000..a79b4d6
--- /dev/null
+++ b/gas/testsuite/gas/s12z/pc-rel-bad.s
@@ -0,0 +1,8 @@
+
+;;; Both the BNE instructions should fail
+;;; because the destination is out of range.
+ bne .label
+ .fill 0x3FFD, 1, 0 ; 0x3FFF minus 3 (the length of the BNE insn)
+.label:
+ .fill 0x4001, 1, 0
+ bne .label
diff --git a/gas/testsuite/gas/s12z/pc-rel-good.d b/gas/testsuite/gas/s12z/pc-rel-good.d
new file mode 100644
index 0000000..acc7e63
--- /dev/null
+++ b/gas/testsuite/gas/s12z/pc-rel-good.d
@@ -0,0 +1,24 @@
+#objdump: -d -r -t
+#name: PC relative branches (close to the limit)
+#source: pc-rel-good.s
+
+
+.*: file format elf32-s12z
+
+SYMBOL TABLE:
+00000000 l d .text 00000000 .text
+00000000 l d .data 00000000 .data
+00000000 l d .bss 00000000 .bss
+00003fff l .text 00000000 .label
+
+
+
+Disassembly of section .text:
+
+00000000 <.label-0x3fff>:
+ 0: 26 bf ff bne .label
+ ...
+
+00003fff <.label>:
+ ...
+ 7fff: 26 c0 00 bne .label
diff --git a/gas/testsuite/gas/s12z/pc-rel-good.s b/gas/testsuite/gas/s12z/pc-rel-good.s
new file mode 100644
index 0000000..f64d197
--- /dev/null
+++ b/gas/testsuite/gas/s12z/pc-rel-good.s
@@ -0,0 +1,6 @@
+
+ bne .label
+ .fill 0x3FFC, 1, 0
+.label:
+ .fill 0x4000, 1, 0
+ bne .label
diff --git a/gas/testsuite/gas/s12z/s12z.exp b/gas/testsuite/gas/s12z/s12z.exp
index a6546d7..d9746d3 100644
--- a/gas/testsuite/gas/s12z/s12z.exp
+++ b/gas/testsuite/gas/s12z/s12z.exp
@@ -90,6 +90,8 @@ run_dump_test opr-idx3-reg
run_dump_test opr-idx3-xysp-24
run_dump_test or-imm
run_dump_test or-opr
+run_dump_test pc-rel-bad
+run_dump_test pc-rel-good
run_dump_test page2-inh
run_dump_test psh-pul
run_dump_test qmul