From 7b02bacd3de266168c23dc6f4f8286a6b4487890 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Tue, 13 May 1997 17:55:41 +0000 Subject: [PATCH] * config/tc-tic80.c (md_apply_fix): Check PC relative relocations for overflow/underflow, only insert lower 15 bits into instruction. --- gas/ChangeLog | 7 +++++++ gas/config/tc-tic80.c | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index adaf79b001a..a0ee8d8e9d4 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +start-sanitize-tic80 +Tue May 13 10:45:56 1997 Fred Fish + + * config/tc-tic80.c (md_apply_fix): Check PC relative relocations + for overflow/underflow, only insert lower 15 bits into instruction. + +end-sanitize-tic80 Mon May 12 13:33:08 1997 H.J. Lu * config/tc-i386.c (pi): Check for RegMMX. diff --git a/gas/config/tc-tic80.c b/gas/config/tc-tic80.c index 9430512f0e7..6c1f490c2a2 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); -- 2.30.2