Check 8 and 16 bit PCREL fixes for overflow, since we bypass the
later overflow checks in write.c. Direct relocs are left alone,
as gcc has been known to take advantage of the silent overflows
when comparing addresses to constant ranges.
+2014-04-02 DJ Delorie <dj@redhat.com>
+
+ * config/tc-rl78.c (md_apply_fix): Add overflow warnings for
+ pc-relative branches.
+
2014-04-02 Nick Clifton <nickc@redhat.com>
PR gas/16765
f->fx_done = 1;
break;
- case BFD_RELOC_8:
case BFD_RELOC_8_PCREL:
+ if ((long)val < -128 || (long)val > 127)
+ as_bad_where (f->fx_file, f->fx_line,
+ _("value of %ld too large for 8-bit branch"),
+ val);
+ /* Fall through. */
+ case BFD_RELOC_8:
op[0] = val;
break;
- case BFD_RELOC_16:
case BFD_RELOC_16_PCREL:
+ if ((long)val < -32768 || (long)val > 32767)
+ as_bad_where (f->fx_file, f->fx_line,
+ _("value of %ld too large for 16-bit branch"),
+ val);
+ /* Fall through. */
+ case BFD_RELOC_16:
case BFD_RELOC_RL78_CODE:
op[0] = val;
op[1] = val >> 8;