diff options
author | DJ Delorie <dj@redhat.com> | 2014-04-02 16:50:29 -0400 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2014-04-02 16:50:29 -0400 |
commit | 0a899fd5acf97c0c9af7c6548e2c0e132148cf78 (patch) | |
tree | 256ddb10408e1bc52d86dc237d641324011229bb /gas | |
parent | cad0da33dc43a207a7c4baf32223831b2d0ac60c (diff) | |
download | gdb-0a899fd5acf97c0c9af7c6548e2c0e132148cf78.zip gdb-0a899fd5acf97c0c9af7c6548e2c0e132148cf78.tar.gz gdb-0a899fd5acf97c0c9af7c6548e2c0e132148cf78.tar.bz2 |
Add checks for overfar branches
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.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 5 | ||||
-rw-r--r-- | gas/config/tc-rl78.c | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index c6b2bb5..c7adc4c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c index ae8f5af..bbbf47b 100644 --- a/gas/config/tc-rl78.c +++ b/gas/config/tc-rl78.c @@ -1310,13 +1310,23 @@ md_apply_fix (struct fix * f ATTRIBUTE_UNUSED, 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; |