diff options
author | Fred Fish <fnf@specifix.com> | 1997-05-13 17:55:41 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1997-05-13 17:55:41 +0000 |
commit | 7b02bacd3de266168c23dc6f4f8286a6b4487890 (patch) | |
tree | 68385dadf417a624189e4df91d3f1e68f5b61cdf /gas/config | |
parent | 8490235019dde8d3b838f3b7f6666ca0eca63911 (diff) | |
download | gdb-7b02bacd3de266168c23dc6f4f8286a6b4487890.zip gdb-7b02bacd3de266168c23dc6f4f8286a6b4487890.tar.gz gdb-7b02bacd3de266168c23dc6f4f8286a6b4487890.tar.bz2 |
* config/tc-tic80.c (md_apply_fix): Check PC relative relocations
for overflow/underflow, only insert lower 15 bits into instruction.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-tic80.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gas/config/tc-tic80.c b/gas/config/tc-tic80.c index 9430512..6c1f490 100644 --- a/gas/config/tc-tic80.c +++ b/gas/config/tc-tic80.c @@ -917,6 +917,7 @@ md_apply_fix (fixP, val) long val; { char *dest = fixP -> fx_frag -> fr_literal + fixP -> fx_where; + int overflow; switch (fixP -> fx_r_type) { @@ -924,9 +925,18 @@ md_apply_fix (fixP, val) md_number_to_chars (dest, (valueT) val, 4); break; case R_MPPCR: - /* FIXME! - should check for overflow of the 15 bit field */ - *dest++ = val >> 2; - *dest = (*dest & 0x80) | val >> 10; + overflow = (val < 0) ? !(val & 0x8000) : (val & 0x8000); + if (overflow) + { + as_bad_where (fixP -> fx_file, fixP -> fx_line, "PC relative target out of range"); + } + else + { + val >>= 2; + *dest++ = val & 0xFF; + val >>= 8; + *dest = (*dest & 0x80) | (val & 0x7F); + } break; case R_ABS: md_number_to_chars (dest, (valueT) val, fixP -> fx_size); |