* config/tc-s390.c (s390_elf_cons): Correct fixups for PLT
[deliverable/binutils-gdb.git] / gas / config / tc-hppa.c
index fe877cbd6505313aabb61354a311086c68ae0b52..cb9b9fbdfb4fb9e18983369c44ef5b63fd41d0f1 100644 (file)
@@ -508,10 +508,10 @@ static int evaluate_absolute PARAMS ((struct pa_it *));
 static unsigned int pa_build_arg_reloc PARAMS ((char *));
 static unsigned int pa_align_arg_reloc PARAMS ((unsigned int, unsigned int));
 static int pa_parse_nullif PARAMS ((char **));
-static int pa_parse_nonneg_cmpsub_cmpltr PARAMS ((char **, int));
-static int pa_parse_neg_cmpsub_cmpltr PARAMS ((char **, int));
-static int pa_parse_neg_add_cmpltr PARAMS ((char **, int));
-static int pa_parse_nonneg_add_cmpltr PARAMS ((char **, int));
+static int pa_parse_nonneg_cmpsub_cmpltr PARAMS ((char **));
+static int pa_parse_neg_cmpsub_cmpltr PARAMS ((char **));
+static int pa_parse_neg_add_cmpltr PARAMS ((char **));
+static int pa_parse_nonneg_add_cmpltr PARAMS ((char **));
 static int pa_parse_cmpb_64_cmpltr PARAMS ((char **));
 static int pa_parse_cmpib_64_cmpltr PARAMS ((char **));
 static int pa_parse_addb_64_cmpltr PARAMS ((char **));
@@ -954,6 +954,11 @@ static const struct pd_reg pre_defined_registers[] =
   {"%isr",   20},
   {"%itmr",  16},
   {"%iva",   14},
+#if TARGET_ARCH_SIZE == 64
+  {"%mrp",    2},
+#else
+  {"%mrp",   31},
+#endif
   {"%pcoq",  18},
   {"%pcsq",  17},
   {"%pidr1",  8},
@@ -1153,6 +1158,20 @@ static struct default_space_dict pa_def_spaces[] =
       } \
   }
 
+/* Variant of CHECK_FIELD for use in md_apply_fix and other places where
+   the current file and line number are not valid.  */
+
+#define CHECK_FIELD_WHERE(FIELD, HIGH, LOW, FILENAME, LINE) \
+  { \
+    if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
+      { \
+        as_bad_where ((FILENAME), (LINE), \
+                     _("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
+                     (int) (FIELD));\
+        break; \
+      } \
+  }
+
 /* Simple alignment checking for FIELD againt ALIGN (a power of two).
    IGNORE is used to suppress the error message.  */
 
@@ -1578,8 +1597,6 @@ pa_ip (str)
       as_fatal (_("Unknown opcode: `%s'"), str);
     }
 
-  save_s = str;
-
   /* Look up the opcode in the has table.  */
   if ((insn = (struct pa_opcode *) hash_find (op_hash, str)) == NULL)
     {
@@ -1672,12 +1689,12 @@ pa_ip (str)
              while (*s == ' ' || *s == '\t')
                s = s + 1;
 
-             if (!strncasecmp(s, "%sar", 4))
+             if (!strncasecmp (s, "%sar", 4))
                {
                  s += 4;
                  continue;
                }
-             else if (!strncasecmp(s, "%cr11", 5))
+             else if (!strncasecmp (s, "%cr11", 5))
                {
                  s += 5;
                  continue;
@@ -1932,7 +1949,7 @@ pa_ip (str)
                /* Handle load cache hint completer.  */
                case 'c':
                  cmpltr = 0;
-                 if (!strncmp(s, ",sl", 3))
+                 if (!strncmp (s, ",sl", 3))
                    {
                      s += 3;
                      cmpltr = 2;
@@ -1942,12 +1959,12 @@ pa_ip (str)
                /* Handle store cache hint completer.  */
                case 'C':
                  cmpltr = 0;
-                 if (!strncmp(s, ",sl", 3))
+                 if (!strncmp (s, ",sl", 3))
                    {
                      s += 3;
                      cmpltr = 2;
                    }
-                 else if (!strncmp(s, ",bc", 3))
+                 else if (!strncmp (s, ",bc", 3))
                    {
                      s += 3;
                      cmpltr = 1;
@@ -1957,7 +1974,7 @@ pa_ip (str)
                /* Handle load and clear cache hint completer.  */
                case 'd':
                  cmpltr = 0;
-                 if (!strncmp(s, ",co", 3))
+                 if (!strncmp (s, ",co", 3))
                    {
                      s += 3;
                      cmpltr = 1;
@@ -1966,7 +1983,7 @@ pa_ip (str)
 
                /* Handle load ordering completer.  */
                case 'o':
-                 if (strncmp(s, ",o", 2) != 0)
+                 if (strncmp (s, ",o", 2) != 0)
                    break;
                  s += 2;
                  continue;
@@ -2235,13 +2252,13 @@ pa_ip (str)
                      else if (*s == 'l')
                        lr = 0;
                      else
-                       as_bad(_("Invalid left/right combination completer"));
+                       as_bad (_("Invalid left/right combination completer"));
 
                      s++;
                      INSERT_FIELD_AND_CONTINUE (opcode, lr, 13);
                    }
                  else
-                   as_bad(_("Invalid left/right combination completer"));
+                   as_bad (_("Invalid left/right combination completer"));
                  break;
 
                /* Handle saturation at 24:25.  */
@@ -2290,14 +2307,14 @@ pa_ip (str)
                              perm = 3;
                              break;
                            default:
-                             as_bad(_("Invalid permutation completer"));
+                             as_bad (_("Invalid permutation completer"));
                            }
                          opcode |= perm << permloc[i];
                        }
                      continue;
                    }
                  else
-                   as_bad(_("Invalid permutation completer"));
+                   as_bad (_("Invalid permutation completer"));
                  break;
 
                default:
@@ -2406,10 +2423,10 @@ pa_ip (str)
 
                  /* Handle non-negated add and branch condition.  */
                  case 'd':
-                   cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1);
+                   cmpltr = pa_parse_nonneg_add_cmpltr (&s);
                    if (cmpltr < 0)
                      {
-                       as_bad (_("Invalid Add and Branch Condition: %c"), *s);
+                       as_bad (_("Invalid Add and Branch Condition"));
                        cmpltr = 0;
                      }
                    INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
@@ -2419,7 +2436,7 @@ pa_ip (str)
                    cmpltr = pa_parse_addb_64_cmpltr (&s);
                    if (cmpltr < 0)
                      {
-                       as_bad (_("Invalid Add and Branch Condition: %c"), *s);
+                       as_bad (_("Invalid Add and Branch Condition"));
                        cmpltr = 0;
                      }
                    else
@@ -2433,11 +2450,11 @@ pa_ip (str)
                     condition.  */
                  case '@':
                    save_s = s;
-                   cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1);
+                   cmpltr = pa_parse_nonneg_add_cmpltr (&s);
                    if (cmpltr < 0)
                      {
                        s = save_s;
-                       cmpltr = pa_parse_neg_add_cmpltr (&s, 1);
+                       cmpltr = pa_parse_neg_add_cmpltr (&s);
                        if (cmpltr < 0)
                          {
                            as_bad (_("Invalid Compare/Subtract Condition"));
@@ -2575,10 +2592,10 @@ pa_ip (str)
 
                  /* Handle a non-negated compare condition.  */
                  case 't':
-                   cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1);
+                   cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s);
                    if (cmpltr < 0)
                      {
-                       as_bad (_("Invalid Compare/Subtract Condition: %c"), *s);
+                       as_bad (_("Invalid Compare/Subtract Condition"));
                        cmpltr = 0;
                      }
                    INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
@@ -2586,14 +2603,14 @@ pa_ip (str)
                  /* Handle a 32 bit compare and branch condition.  */
                  case 'n':
                    save_s = s;
-                   cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1);
+                   cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s);
                    if (cmpltr < 0)
                      {
                        s = save_s;
-                       cmpltr = pa_parse_neg_cmpsub_cmpltr (&s, 1);
+                       cmpltr = pa_parse_neg_cmpsub_cmpltr (&s);
                        if (cmpltr < 0)
                          {
-                           as_bad (_("Invalid Compare and Branch Condition."));
+                           as_bad (_("Invalid Compare and Branch Condition"));
                            cmpltr = 0;
                          }
                        else
@@ -4055,7 +4072,7 @@ tc_gen_reloc (section, fixp)
 
   if (codes == NULL)
     {
-      as_bad (_("Cannot handle fixup at %s:%d"), fixp->fx_file, fixp->fx_line);
+      as_bad_where (fixp->fx_file, fixp->fx_line, _("Cannot handle fixup"));
       abort ();
     }
 
@@ -4426,8 +4443,9 @@ md_apply_fix (fixP, valp)
   hppa_fixP = (struct hppa_fix_struct *) fixP->tc_fix_data;
   if (hppa_fixP == NULL)
     {
-      printf (_("no hppa_fixup entry for fixup type 0x%x at %s:%d"),
-             fixP->fx_r_type, fixP->fx_file, fixP->fx_line);
+      as_bad_where (fixP->fx_file, fixP->fx_line,
+                   _("no hppa_fixup entry for fixup type 0x%x"),
+                   fixP->fx_r_type);
       return 0;
     }
 
@@ -4493,14 +4511,16 @@ md_apply_fix (fixP, valp)
   switch (fmt)
     {
     case 10:
-      CHECK_FIELD (new_val, 8191, -8192, 0);
+      CHECK_FIELD_WHERE (new_val, 8191, -8192,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val;
 
       insn = (insn & ~ 0x3ff1) | (((val & 0x1ff8) << 1)
                                  | ((val & 0x2000) >> 13));
       break;
     case -11:
-      CHECK_FIELD (new_val, 8191, -8192, 0);
+      CHECK_FIELD_WHERE (new_val, 8191, -8192,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val;
 
       insn = (insn & ~ 0x3ff9) | (((val & 0x1ffc) << 1)
@@ -4508,7 +4528,8 @@ md_apply_fix (fixP, valp)
       break;
       /* Handle all opcodes with the 'j' operand type.  */
     case 14:
-      CHECK_FIELD (new_val, 8191, -8192, 0);
+      CHECK_FIELD_WHERE (new_val, 8191, -8192,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val;
 
       insn = ((insn & ~ 0x3fff) | low_sign_unext (val, 14));
@@ -4516,7 +4537,8 @@ md_apply_fix (fixP, valp)
 
       /* Handle all opcodes with the 'k' operand type.  */
     case 21:
-      CHECK_FIELD (new_val, 1048575, -1048576, 0);
+      CHECK_FIELD_WHERE (new_val, 1048575, -1048576,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val;
 
       insn = (insn & ~ 0x1fffff) | re_assemble_21 (val);
@@ -4524,7 +4546,8 @@ md_apply_fix (fixP, valp)
 
       /* Handle all the opcodes with the 'i' operand type.  */
     case 11:
-      CHECK_FIELD (new_val, 1023, -1024, 0);
+      CHECK_FIELD_WHERE (new_val, 1023, -1024,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val;
 
       insn = (insn & ~ 0x7ff) | low_sign_unext (val, 11);
@@ -4532,7 +4555,8 @@ md_apply_fix (fixP, valp)
 
       /* Handle all the opcodes with the 'w' operand type.  */
     case 12:
-      CHECK_FIELD (new_val - 8, 8191, -8192, 0);
+      CHECK_FIELD_WHERE (new_val - 8, 8191, -8192,
+                        fixP->fx_file, fixP->fx_line);
       val = new_val - 8;
 
       insn = (insn & ~ 0x1ffd) | re_assemble_12 (val >> 2);
@@ -4547,9 +4571,11 @@ md_apply_fix (fixP, valp)
           range target, then we want to complain.  */
        if (fixP->fx_r_type == (int) R_HPPA_PCREL_CALL
            && (insn & 0xffe00000) == 0xe8000000)
-         CHECK_FIELD (distance - 8, 262143, -262144, 0);
+         CHECK_FIELD_WHERE (distance - 8, 262143, -262144,
+                            fixP->fx_file, fixP->fx_line);
 
-       CHECK_FIELD (new_val - 8, 262143, -262144, 0);
+       CHECK_FIELD_WHERE (new_val - 8, 262143, -262144,
+                          fixP->fx_file, fixP->fx_line);
        val = new_val - 8;
 
        insn = (insn & ~ 0x1f1ffd) | re_assemble_17 (val >> 2);
@@ -4564,9 +4590,11 @@ md_apply_fix (fixP, valp)
           range target, then we want to complain.  */
        if (fixP->fx_r_type == (int) R_HPPA_PCREL_CALL
            && (insn & 0xffe00000) == 0xe8000000)
-         CHECK_FIELD (distance - 8, 8388607, -8388608, 0);
+         CHECK_FIELD_WHERE (distance - 8, 8388607, -8388608,
+                            fixP->fx_file, fixP->fx_line);
 
-       CHECK_FIELD (new_val - 8, 8388607, -8388608, 0);
+       CHECK_FIELD_WHERE (new_val - 8, 8388607, -8388608,
+                          fixP->fx_file, fixP->fx_line);
        val = new_val - 8;
 
        insn = (insn & ~ 0x3ff1ffd) | re_assemble_22 (val >> 2);
@@ -4593,7 +4621,8 @@ md_apply_fix (fixP, valp)
       break;
 
     default:
-      as_bad (_("Unknown relocation encountered in md_apply_fix."));
+      as_bad_where (fixP->fx_file, fixP->fx_line,
+                   _("Unknown relocation encountered in md_apply_fix."));
       return 0;
     }
 
@@ -5317,16 +5346,11 @@ pa_parse_nullif (s)
 }
 
 /* Parse a non-negated compare/subtract completer returning the
-   number (for encoding in instrutions) of the given completer.
-
-   ISBRANCH specifies whether or not this is parsing a condition
-   completer for a branch (vs a nullification completer for a
-   computational instruction.  */
+   number (for encoding in instrutions) of the given completer.  */
 
 static int
-pa_parse_nonneg_cmpsub_cmpltr (s, isbranch)
+pa_parse_nonneg_cmpsub_cmpltr (s)
      char **s;
-     int isbranch;
 {
   int cmpltr;
   char *name = *s + 1;
@@ -5373,7 +5397,7 @@ pa_parse_nonneg_cmpsub_cmpltr (s, isbranch)
        }
       /* If we have something like addb,n then there is no condition
          completer.  */
-      else if (strcasecmp (name, "n") == 0 && isbranch)
+      else if (strcasecmp (name, "n") == 0)
        {
          cmpltr = 0;
          nullify = 1;
@@ -5393,16 +5417,11 @@ pa_parse_nonneg_cmpsub_cmpltr (s, isbranch)
 }
 
 /* Parse a negated compare/subtract completer returning the
-   number (for encoding in instrutions) of the given completer.
-
-   ISBRANCH specifies whether or not this is parsing a condition
-   completer for a branch (vs a nullification completer for a
-   computational instruction.  */
+   number (for encoding in instrutions) of the given completer.  */
 
 static int
-pa_parse_neg_cmpsub_cmpltr (s, isbranch)
+pa_parse_neg_cmpsub_cmpltr (s)
      char **s;
-     int isbranch;
 {
   int cmpltr;
   char *name = *s + 1;
@@ -5453,7 +5472,7 @@ pa_parse_neg_cmpsub_cmpltr (s, isbranch)
        }
       /* If we have something like addb,n then there is no condition
          completer.  */
-      else if (strcasecmp (name, "n") == 0 && isbranch)
+      else if (strcasecmp (name, "n") == 0)
        {
          cmpltr = 0;
          nullify = 1;
@@ -5632,21 +5651,17 @@ pa_parse_cmpib_64_cmpltr (s)
 }
 
 /* Parse a non-negated addition completer returning the number
-   (for encoding in instrutions) of the given completer.
-
-   ISBRANCH specifies whether or not this is parsing a condition
-   completer for a branch (vs a nullification completer for a
-   computational instruction.  */
+   (for encoding in instrutions) of the given completer.  */
 
 static int
-pa_parse_nonneg_add_cmpltr (s, isbranch)
+pa_parse_nonneg_add_cmpltr (s)
      char **s;
-     int isbranch;
 {
   int cmpltr;
   char *name = *s + 1;
   char c;
   char *save_s = *s;
+  int nullify = 0;
 
   cmpltr = 0;
   if (**s == ',')
@@ -5686,9 +5701,10 @@ pa_parse_nonneg_add_cmpltr (s, isbranch)
        }
       /* If we have something like addb,n then there is no condition
          completer.  */
-      else if (strcasecmp (name, "n") == 0 && isbranch)
+      else if (strcasecmp (name, "n") == 0)
        {
          cmpltr = 0;
+         nullify = 1;
        }
       else
        {
@@ -5698,28 +5714,24 @@ pa_parse_nonneg_add_cmpltr (s, isbranch)
     }
 
   /* Reset pointers if this was really a ,n for a branch instruction.  */
-  if (cmpltr == 0 && *name == 'n' && isbranch)
+  if (nullify)
     *s = save_s;
 
   return cmpltr;
 }
 
 /* Parse a negated addition completer returning the number
-   (for encoding in instrutions) of the given completer.
-
-   ISBRANCH specifies whether or not this is parsing a condition
-   completer for a branch (vs a nullification completer for a
-   computational instruction).  */
+   (for encoding in instrutions) of the given completer.  */
 
 static int
-pa_parse_neg_add_cmpltr (s, isbranch)
+pa_parse_neg_add_cmpltr (s)
      char **s;
-     int isbranch;
 {
   int cmpltr;
   char *name = *s + 1;
   char c;
   char *save_s = *s;
+  int nullify = 0;
 
   cmpltr = 0;
   if (**s == ',')
@@ -5763,9 +5775,10 @@ pa_parse_neg_add_cmpltr (s, isbranch)
        }
       /* If we have something like addb,n then there is no condition
          completer.  */
-      else if (strcasecmp (name, "n") == 0 && isbranch)
+      else if (strcasecmp (name, "n") == 0)
        {
          cmpltr = 0;
+         nullify = 1;
        }
       else
        {
@@ -5775,7 +5788,7 @@ pa_parse_neg_add_cmpltr (s, isbranch)
     }
 
   /* Reset pointers if this was really a ,n for a branch instruction.  */
-  if (cmpltr == 0 && *name == 'n' && isbranch)
+  if (nullify)
     *s = save_s;
 
   return cmpltr;
This page took 0.030252 seconds and 4 git commands to generate.