Add Dmitry Diky to maintainers list as msp430 maintainer
[deliverable/binutils-gdb.git] / gas / config / tc-arc.c
index 112c30adc4b0dab8fca586d4b9abd873c86caf06..3bdb160aab8cbca70a6aec882f7455ec5ec18336 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-arc.c -- Assembler for the ARC
-   Copyright 1994, 1995, 1997, 1999, 2000, 2001
+   Copyright 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Contributed by Doug Evans (dje@cygnus.com).
 
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include "libiberty.h"
 #include "as.h"
+#include "struc-symbol.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
 #include "opcode/arc.h"
@@ -93,8 +94,6 @@ const pseudo_typeS md_pseudo_table[] = {
   { "option", arc_option, 0 },
   { "cpu", arc_option, 0 },
   { "block", s_space, 0 },
-  { "file", dwarf2_directive_file, 0 },
-  { "loc", dwarf2_directive_loc, 0 },
   { "extcondcode", arc_extoper, 0 },
   { "extcoreregister", arc_extoper, 1 },
   { "extauxregister", arc_extoper, 2 },
@@ -329,17 +328,7 @@ arc_insert_operand (insn, operand, mods, reg, val, file, line)
        test = val;
 
       if (test < (offsetT) min || test > (offsetT) max)
-       {
-         const char *err =
-           "operand out of range (%s not between %ld and %ld)";
-         char buf[100];
-
-         sprint_value (buf, test);
-         if (file == (char *) NULL)
-           as_warn (err, buf, min, max);
-         else
-           as_warn_where (file, line, err, buf, min, max);
-       }
+       as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line);
     }
 
   if (operand->insert)
@@ -447,15 +436,7 @@ md_assemble (str)
          /* Non operand chars must match exactly.  */
          if (*syn != '%' || *++syn == '%')
            {
-             /* Handle '+' specially as we want to allow "ld r0,[sp-4]".  */
-             /* ??? The syntax has changed to [sp,-4].  */
-             if (0 && *syn == '+' && *str == '-')
-               {
-                 /* Skip over syn's +, but leave str's - alone.
-                    That makes the case identical to "ld r0,[sp+-4]".  */
-                 ++syn;
-               }
-             else if (*str == *syn)
+            if (*str == *syn)
                {
                  if (*syn == ' ')
                    past_opcode_p = 1;
@@ -579,7 +560,7 @@ md_assemble (str)
                                               NULL);
                  else
                    insn |= suf->value << operand->shift;
-
+                 suffix = suf;
                  str = t;
                  found = 1;
                }
@@ -834,7 +815,7 @@ md_assemble (str)
                 operands residing in the insn, but instead just use the
                 operand index.  This lets us easily handle fixups for any
                 operand type, although that is admittedly not a very exciting
-                feature.  We pick a BFD reloc type in md_apply_fix.
+                feature.  We pick a BFD reloc type in md_apply_fix3.
 
                 Limm values (4 byte immediate "constants") must be treated
                 normally because they're not part of the actual insn word
@@ -906,11 +887,6 @@ arc_extoper (opertype)
   name = input_line_pointer;
   c = get_symbol_end ();
   name = xstrdup (name);
-  if (NULL == name)
-    {
-      ignore_rest_of_line ();
-      return;
-    }
 
   p = name;
   while (*p)
@@ -1137,7 +1113,7 @@ static void
 arc_extinst (ignore)
      int ignore ATTRIBUTE_UNUSED;
 {
-  unsigned char syntax[129];
+  char syntax[129];
   char *name;
   char *p;
   char c;
@@ -1154,11 +1130,6 @@ arc_extinst (ignore)
   name = input_line_pointer;
   c = get_symbol_end ();
   name = xstrdup (name);
-  if (NULL == name)
-    {
-      ignore_rest_of_line ();
-      return;
-    }
   strcpy (syntax, name);
   name_len = strlen (name);
 
@@ -1306,18 +1277,7 @@ arc_extinst (ignore)
   strcat (syntax, "%S%L");
 
   ext_op = (struct arc_opcode *) xmalloc (sizeof (struct arc_opcode));
-  if (NULL == ext_op)
-    {
-      ignore_rest_of_line ();
-      return;
-    }
-
   ext_op->syntax = xstrdup (syntax);
-  if (NULL == ext_op->syntax)
-    {
-      ignore_rest_of_line ();
-      return;
-    }
 
   ext_op->mask  = I (-1) | ((0x3 == opcode) ? C (-1) : 0);
   ext_op->value = I (opcode) | ((0x3 == opcode) ? C (subopcode) : 0);
@@ -1476,7 +1436,6 @@ arc_common (localScope)
   symbolP->bsym->flags |= BSF_OBJECT;
 
   demand_empty_rest_of_line ();
-  return;
 }
 \f
 /* Select the cpu we're assembling for.  */
@@ -1547,7 +1506,6 @@ md_atof (type, litP, sizeP)
   LITTLENUM_TYPE words[MAX_LITTLENUMS];
   LITTLENUM_TYPE *wordP;
   char *t;
-  char * atof_ieee PARAMS ((char *, int, LITTLENUM_TYPE *));
 
   switch (type)
     {
@@ -1679,50 +1637,52 @@ md_operand (expressionP)
 {
   char *p = input_line_pointer;
 
-  if (*p == '%')
-    if (strncmp (p, "%st(", 4) == 0)
-      {
-       input_line_pointer += 4;
-       expression (expressionP);
-       if (*input_line_pointer != ')')
-         {
-           as_bad ("missing ')' in %%-op");
-           return;
-         }
-       ++input_line_pointer;
-       arc_code_symbol (expressionP);
-      }
-    else
-      {
-       /* It could be a register.  */
-       int i, l;
-       struct arc_ext_operand_value *ext_oper = arc_ext_operands;
-       p++;
+  if (*p != '%')
+    return;
 
-       while (ext_oper)
-         {
-           l = strlen (ext_oper->operand.name);
-           if (!strncmp (p, ext_oper->operand.name, l) && !ISALNUM (*(p + l)))
-             {
-               input_line_pointer += l + 1;
-               expressionP->X_op = O_register;
-               expressionP->X_add_number = (int) &ext_oper->operand;
-               return;
-             }
-           ext_oper = ext_oper->next;
-         }
-       for (i = 0; i < arc_reg_names_count; i++)
-         {
-           l = strlen (arc_reg_names[i].name);
-           if (!strncmp (p, arc_reg_names[i].name, l) && !ISALNUM (*(p + l)))
-             {
-               input_line_pointer += l + 1;
-               expressionP->X_op = O_register;
-               expressionP->X_add_number = (int) &arc_reg_names[i];
-               break;
-             }
-         }
-      }
+  if (strncmp (p, "%st(", 4) == 0)
+    {
+      input_line_pointer += 4;
+      expression (expressionP);
+      if (*input_line_pointer != ')')
+       {
+         as_bad ("missing ')' in %%-op");
+         return;
+       }
+      ++input_line_pointer;
+      arc_code_symbol (expressionP);
+    }
+  else
+    {
+      /* It could be a register.  */
+      int i, l;
+      struct arc_ext_operand_value *ext_oper = arc_ext_operands;
+      p++;
+
+      while (ext_oper)
+       {
+         l = strlen (ext_oper->operand.name);
+         if (!strncmp (p, ext_oper->operand.name, l) && !ISALNUM (*(p + l)))
+           {
+             input_line_pointer += l + 1;
+             expressionP->X_op = O_register;
+             expressionP->X_add_number = (int) &ext_oper->operand;
+             return;
+           }
+         ext_oper = ext_oper->next;
+       }
+      for (i = 0; i < arc_reg_names_count; i++)
+       {
+         l = strlen (arc_reg_names[i].name);
+         if (!strncmp (p, arc_reg_names[i].name, l) && !ISALNUM (*(p + l)))
+           {
+             input_line_pointer += l + 1;
+             expressionP->X_op = O_register;
+             expressionP->X_add_number = (int) &arc_reg_names[i];
+             break;
+           }
+       }
+    }
 }
 
 /* We have no need to default values of symbols.
@@ -1801,13 +1761,6 @@ long
 md_pcrel_from (fixP)
      fixS *fixP;
 {
-  if (fixP->fx_addsy != (symbolS *) NULL
-      && ! S_IS_DEFINED (fixP->fx_addsy))
-    {
-      /* The symbol is undefined.  Let the linker figure it out.  */
-      return 0;
-    }
-
   /* Return the address of the delay slot.  */
   return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
 }
@@ -1841,7 +1794,7 @@ get_arc_exp_reloc_type (data_p, default_type, exp, expnew)
      expressionS *expnew;
 {
   /* If the expression is "symbol >> 2" we must change it to just "symbol",
-     as fix_new_exp can't handle it.  Similarily for (symbol - symbol) >> 2.
+     as fix_new_exp can't handle it.  Similarly for (symbol - symbol) >> 2.
      That's ok though.  What's really going on here is that we're using
      ">> 2" as a special syntax for specifying BFD_RELOC_ARC_B26.  */
 
@@ -1880,59 +1833,27 @@ get_arc_exp_reloc_type (data_p, default_type, exp, expnew)
    and we attempt to completely resolve the reloc.  If we can not do
    that, we determine the correct reloc code and put it back in the fixup.  */
 
-int
-md_apply_fix3 (fixP, valueP, seg)
+void
+md_apply_fix3 (fixP, valP, seg)
      fixS *fixP;
-     valueT *valueP;
+     valueT * valP;
      segT seg;
 {
-#if 0
-  char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-#endif
-  valueT value;
-
-  /* FIXME FIXME FIXME: The value we are passed in *valueP includes
-     the symbol values.  Since we are using BFD_ASSEMBLER, if we are
-     doing this relocation the code in write.c is going to call
-     bfd_perform_relocation, which is also going to use the symbol
-     value.  That means that if the reloc is fully resolved we want to
-     use *valueP since bfd_perform_relocation is not being used.
-     However, if the reloc is not fully resolved we do not want to use
-     *valueP, and must use fx_offset instead.  However, if the reloc
-     is PC relative, we do want to use *valueP since it includes the
-     result of md_pcrel_from.  This is confusing.  */
+  valueT value = * valP;
 
   if (fixP->fx_addsy == (symbolS *) NULL)
-    {
-      value = *valueP;
-      fixP->fx_done = 1;
-    }
+    fixP->fx_done = 1;
+
   else if (fixP->fx_pcrel)
     {
-      value = *valueP;
-      /* ELF relocations are against symbols.
-        If this symbol is in a different section then we need to leave it for
-        the linker to deal with.  Unfortunately, md_pcrel_from can't tell,
-        so we have to undo it's effects here.  */
-      if (S_IS_DEFINED (fixP->fx_addsy)
-         && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+      /* Hack around bfd_install_relocation brain damage.  */
+      if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
        value += md_pcrel_from (fixP);
     }
-  else
-    {
-      value = fixP->fx_offset;
-      if (fixP->fx_subsy != (symbolS *) NULL)
-       {
-         if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
-           value -= S_GET_VALUE (fixP->fx_subsy);
-         else
-           {
-             /* We can't actually support subtracting a symbol.  */
-             as_bad_where (fixP->fx_file, fixP->fx_line,
-                           "expression too complex");
-           }
-       }
-    }
+
+  /* We can't actually support subtracting a symbol.  */
+  if (fixP->fx_subsy != NULL)
+    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
 
   if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
     {
@@ -1962,7 +1883,7 @@ md_apply_fix3 (fixP, valueP, seg)
       if (fixP->fx_done)
        {
          /* Nothing else to do here.  */
-         return 1;
+         return;
        }
 
       /* Determine a BFD reloc value based on the operand information.
@@ -1997,7 +1918,7 @@ md_apply_fix3 (fixP, valueP, seg)
          as_bad_where (fixP->fx_file, fixP->fx_line,
                        "unresolved expression that must be resolved");
          fixP->fx_done = 1;
-         return 1;
+         return;
        }
     }
   else
@@ -2016,12 +1937,6 @@ md_apply_fix3 (fixP, valueP, seg)
          md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
                              value, 4);
          break;
-#if 0
-       case BFD_RELOC_64:
-         md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
-                             value, 8);
-         break;
-#endif
        case BFD_RELOC_ARC_B26:
          /* If !fixP->fx_done then `value' is an implicit addend.
             We must shift it right by 2 in this case as well because the
@@ -2035,10 +1950,6 @@ md_apply_fix3 (fixP, valueP, seg)
          abort ();
        }
     }
-
-  fixP->fx_addnumber = value;
-
-  return 1;
 }
 
 /* Translate internal representation of relocation info to BFD target
@@ -2052,8 +1963,9 @@ tc_gen_reloc (section, fixP)
   arelent *reloc;
 
   reloc = (arelent *) xmalloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
 
-  reloc->sym_ptr_ptr = &fixP->fx_addsy->bsym;
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
   if (reloc->howto == (reloc_howto_type *) NULL)
@@ -2068,8 +1980,7 @@ tc_gen_reloc (section, fixP)
   assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
 
   /* Set addend to account for PC being advanced one insn before the
-     target address is computed, drop fx_addnumber as it is handled
-     elsewhere mlm  */
+     target address is computed.  */
 
   reloc->addend = (fixP->fx_pcrel ? -4 : 0);
 
This page took 0.029169 seconds and 4 git commands to generate.