* config/tc-tic80.c (md_apply_fix): Check PC relative relocations
authorFred Fish <fnf@specifix.com>
Tue, 13 May 1997 17:55:41 +0000 (17:55 +0000)
committerFred Fish <fnf@specifix.com>
Tue, 13 May 1997 17:55:41 +0000 (17:55 +0000)
for overflow/underflow, only insert lower 15 bits into instruction.

gas/ChangeLog
gas/config/tc-tic80.c

index adaf79b001a00ca40d2be499e42c2467e88376ec..a0ee8d8e9d4f980f39e0bc7937fd7d4004de112a 100644 (file)
@@ -1,3 +1,10 @@
+start-sanitize-tic80
+Tue May 13 10:45:56 1997  Fred Fish  <fnf@cygnus.com>
+
+       * 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  <hjl@gnu.ai.mit.edu>
 
        * config/tc-i386.c (pi): Check for RegMMX.
index 9430512f0e7b930e6cd9cc05633f1c9a702e1519..6c1f490c2a255760d9449f5f2315d9ea06a97bd7 100644 (file)
@@ -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);
This page took 0.029463 seconds and 4 git commands to generate.