+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.
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."));
--- /dev/null
+#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:
--- /dev/null
+.*: Assembler messages:
+.*:4: Error: Value out of 16-bit range.
+.*:8: Error: Value out of 16-bit range.
--- /dev/null
+
+;;; 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
--- /dev/null
+#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
--- /dev/null
+
+ bne .label
+ .fill 0x3FFC, 1, 0
+.label:
+ .fill 0x4000, 1, 0
+ bne .label
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