ChangeLog rotation
[deliverable/binutils-gdb.git] / gas / config / tc-tic4x.c
index c27c8d1172aab9e6157ffd9aed73b725dc09a7af..241046435dc550b3042721dddd6805cf09088c08 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-tic4x.c -- Assemble for the Texas Instruments TMS320C[34]x.
-   Copyright (C) 1997-2015 Free Software Foundation, Inc.
+   Copyright (C) 1997-2018 Free Software Foundation, Inc.
 
    Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
 
@@ -124,7 +124,8 @@ typedef struct tic4x_insn
     unsigned int nchars;       /* This is always 4 for the C30.  */
     unsigned long opcode;      /* Opcode number.  */
     expressionS exp;           /* Expression required for relocation.  */
-    int reloc;                 /* Relocation type required.  */
+    /* Relocation type required.  */
+    bfd_reloc_code_real_type reloc;
     int pcrel;                 /* True if relocation PC relative.  */
     char *pname;               /* Name of instruction in parallel.  */
     unsigned int num_operands; /* Number of operands in total.  */
@@ -222,7 +223,7 @@ const char FLT_CHARS[] = "fFilsS";
 extern FLONUM_TYPE generic_floating_point_number;
 
 /* Precision in LittleNums.  */
-#define MAX_PRECISION (4)       /* Its a bit overkill for us, but the code
+#define MAX_PRECISION (4)       /* It's a bit overkill for us, but the code
                                    requires it... */
 #define S_PRECISION (1)                /* Short float constants 16-bit.  */
 #define F_PRECISION (2)                /* Float and double types 32-bit.  */
@@ -618,7 +619,7 @@ tic4x_atof (char *str, char what_kind, LITTLENUM_TYPE *words)
 }
 
 static void
-tic4x_insert_reg (char *regname, int regnum)
+tic4x_insert_reg (const char *regname, int regnum)
 {
   char buf[32];
   int i;
@@ -634,7 +635,7 @@ tic4x_insert_reg (char *regname, int regnum)
 }
 
 static void
-tic4x_insert_sym (char *symname, int value)
+tic4x_insert_sym (const char *symname, int value)
 {
   symbolS *symbolP;
 
@@ -713,7 +714,6 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
   char c;
   char *name;
   char *str;
-  char *tmp;
 
   SKIP_WHITESPACE ();
   str = input_line_pointer;
@@ -727,19 +727,14 @@ tic4x_asg (int x ATTRIBUTE_UNUSED)
       return;
     }
   *input_line_pointer++ = '\0';
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
-  tmp = xmalloc (strlen (str) + 1);
-  strcpy (tmp, str);
-  str = tmp;
-  tmp = xmalloc (strlen (name) + 1);
-  strcpy (tmp, name);
-  name = tmp;
+  c = get_symbol_name (&name); /* Get terminator.  */
+  str = xstrdup (str);
+  name = xstrdup (name);
   if (hash_find (tic4x_asg_hash, name))
     hash_replace (tic4x_asg_hash, name, (void *) str);
   else
     hash_insert (tic4x_asg_hash, name, (void *) str);
-  *input_line_pointer = c;
+  (void) restore_line_pointer (c);
   demand_empty_rest_of_line ();
 }
 
@@ -759,8 +754,9 @@ tic4x_bss (int x ATTRIBUTE_UNUSED)
   current_subseg = now_subseg; /* Save current subseg.  */
 
   SKIP_WHITESPACE ();
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   if (c != ',')
     {
       as_bad (_(".bss size argument missing\n"));
@@ -807,11 +803,10 @@ tic4x_globl (int ignore ATTRIBUTE_UNUSED)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (&name);
       symbolP = symbol_find_or_make (name);
       *input_line_pointer = c;
-      SKIP_WHITESPACE ();
+      SKIP_WHITESPACE_AFTER_NAME ();
       S_SET_STORAGE_CLASS (symbolP, C_EXT);
       S_SET_EXTERNAL (symbolP);
       if (c == ',')
@@ -908,7 +903,7 @@ tic4x_stringer (int append_zero)
               as_bad (_("Non-constant symbols not allowed\n"));
               return;
             }
-          exp.X_add_number &= 255; /* Limit numeber to 8-bit */
+          exp.X_add_number &= 255; /* Limit number to 8-bit */
          emit_expr (&exp, 1);
           bytes++;
        }
@@ -939,10 +934,9 @@ tic4x_eval (int x ATTRIBUTE_UNUSED)
       as_bad (_("Symbol missing\n"));
       return;
     }
-  name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&name); /* Get terminator.  */
   tic4x_insert_sym (name, value);
-  *input_line_pointer++ = c;
+  (void) restore_line_pointer (c);
   demand_empty_rest_of_line ();
 }
 
@@ -967,11 +961,11 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
     input_line_pointer++;
-  section_name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&section_name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   input_line_pointer++;                /* Skip null symbol terminator.  */
-  name = xmalloc (input_line_pointer - section_name + 1);
-  strcpy (name, section_name);
+  name = xstrdup (section_name);
 
   /* TI C from version 5.0 allows a section name to contain a
      subsection name as well. The subsection name is separated by a
@@ -980,13 +974,16 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
      Volker Kuhlmann  <v.kuhlmann@elec.canterbury.ac.nz>.  */
   if (c == ':')
     {
-      c = get_symbol_end ();   /* Get terminator.  */
+      char *subname;
+      c = get_symbol_name (&subname);  /* Get terminator.  */
+      if (c == '"')
+       c = * ++ input_line_pointer;
       input_line_pointer++;    /* Skip null symbol terminator.  */
       as_warn (_(".sect: subsection name ignored"));
     }
 
   /* We might still have a '"' to discard, but the character after a
-     symbol name will be overwritten with a \0 by get_symbol_end()
+     symbol name will be overwritten with a \0 by get_symbol_name()
      [VK].  */
 
   if (c == ',')
@@ -1014,7 +1011,7 @@ tic4x_sect (int x ATTRIBUTE_UNUSED)
                 bfd_errmsg (bfd_get_error ()));
     }
 
-  /* If the last character overwritten by get_symbol_end() was an
+  /* If the last character overwritten by get_symbol_name() was an
      end-of-line, we must restore it or the end of the line will not be
      recognised and scanning extends into the next line, stopping with
      an error (blame Volker Kuhlmann <v.kuhlmann@elec.canterbury.ac.nz>
@@ -1037,8 +1034,9 @@ tic4x_set (int x ATTRIBUTE_UNUSED)
       char c;
       char *name;
 
-      name = input_line_pointer;
-      c = get_symbol_end ();   /* Get terminator.  */
+      c = get_symbol_name (&name);     /* Get terminator.  */
+      if (c == '"')
+       c = * ++ input_line_pointer;
       if (c != ',')
        {
          as_bad (_(".set syntax invalid\n"));
@@ -1073,11 +1071,11 @@ tic4x_usect (int x ATTRIBUTE_UNUSED)
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
     input_line_pointer++;
-  section_name = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&section_name); /* Get terminator.  */
+  if (c == '"')
+    c = * ++ input_line_pointer;
   input_line_pointer++;                /* Skip null symbol terminator.  */
-  name = xmalloc (input_line_pointer - section_name + 1);
-  strcpy (name, section_name);
+  name = xstrdup (section_name);
 
   if (c == ',')
     input_line_pointer =
@@ -1235,7 +1233,7 @@ tic4x_inst_insert (const tic4x_inst_t *inst)
 
 /* Make a new instruction template.  */
 static tic4x_inst_t *
-tic4x_inst_make (char *name, unsigned long opcode, char *args)
+tic4x_inst_make (const char *name, unsigned long opcode, const char *args)
 {
   static tic4x_inst_t *insts = NULL;
   static char *names = NULL;
@@ -1244,10 +1242,9 @@ tic4x_inst_make (char *name, unsigned long opcode, char *args)
   if (insts == NULL)
     {
       /* Allocate memory to store name strings.  */
-      names = (char *) xmalloc (sizeof (char) * 8192);
+      names = XNEWVEC (char, 8192);
       /* Allocate memory for additional insts.  */
-      insts = (tic4x_inst_t *)
-       xmalloc (sizeof (tic4x_inst_t) * 1024);
+      insts = XNEWVEC (tic4x_inst_t, 1024);
     }
   insts[iindex].name = names;
   insts[iindex].opcode = opcode;
@@ -1267,7 +1264,7 @@ tic4x_inst_make (char *name, unsigned long opcode, char *args)
 static int
 tic4x_inst_add (const tic4x_inst_t *insts)
 {
-  char *s = insts->name;
+  const char *s = insts->name;
   char *d;
   unsigned int i;
   int ok = 1;
@@ -1291,7 +1288,7 @@ tic4x_inst_add (const tic4x_inst_t *insts)
            {
              tic4x_inst_t *inst;
              int k = 0;
-             char *c = tic4x_conds[i].name;
+             const char *c = tic4x_conds[i].name;
              char *e = d;
 
              while (*c)
@@ -1403,7 +1400,7 @@ static int
 tic4x_indirect_parse (tic4x_operand_t *operand,
                      const tic4x_indirect_t *indirect)
 {
-  char *n = indirect->name;
+  const char *n = indirect->name;
   char *s = input_line_pointer;
   char *b;
   symbolS *symbolP;
@@ -1513,17 +1510,16 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
   input_line_pointer = s;
   SKIP_WHITESPACE ();
 
-  str = input_line_pointer;
-  c = get_symbol_end ();       /* Get terminator.  */
+  c = get_symbol_name (&str);  /* Get terminator.  */
   new_pointer = input_line_pointer;
   if (strlen (str) && (entry = hash_find (tic4x_asg_hash, str)) != NULL)
     {
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       input_line_pointer = (char *) entry;
     }
   else
     {
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
       input_line_pointer = str;
     }
 
@@ -1557,10 +1553,10 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
       /* Allow ori ^foo, ar0 to be equivalent to ldi .hi.foo, ar0  */
       /* WARNING : The TI C40 assembler cannot do this.  */
       else if (exp->X_op == O_symbol)
-       {
-         operand->mode = M_HI;
-         break;
-       }
+       operand->mode = M_HI;
+      else
+       as_bad (_("Expecting a constant value"));
+      break;
 
     case '#':
       input_line_pointer = tic4x_expression (++input_line_pointer, exp);
@@ -1580,14 +1576,11 @@ tic4x_operand_parse (char *s, tic4x_operand_t *operand)
       /* Allow ori foo, ar0 to be equivalent to ldi .lo.foo, ar0  */
       /* WARNING : The TI C40 assembler cannot do this.  */
       else if (exp->X_op == O_symbol)
-       {
-         operand->mode = M_IMMED;
-         break;
-       }
-
+       operand->mode = M_IMMED;
       else
        as_bad (_("Expecting a constant value"));
       break;
+
     case '\\':
 #endif
     case '@':
@@ -2360,7 +2353,7 @@ tic4x_insn_check (tic4x_insn_t *tinsn)
       if (tinsn->operands[1].mode == M_REGISTER
          && tinsn->operands[tinsn->num_operands-1].mode == M_REGISTER
          && tinsn->operands[1].expr.X_add_number == tinsn->operands[tinsn->num_operands-1].expr.X_add_number )
-        as_warn (_("Equal parallell destination registers, one result will be discarded"));
+        as_warn (_("Equal parallel destination registers, one result will be discarded"));
     }
 }
 
@@ -2549,7 +2542,7 @@ tic4x_cleanup (void)
    of chars emitted is stored in *sizeP.  An error message is
    returned, or NULL on OK.  */
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   int prec;
@@ -2645,9 +2638,11 @@ md_apply_fix (fixS *fixP, valueT *value, segT seg ATTRIBUTE_UNUSED)
     {
     case BFD_RELOC_32:
       buf[3] = val >> 24;
+      /* Fall through.  */
     case BFD_RELOC_24:
     case BFD_RELOC_24_PCREL:
       buf[2] = val >> 16;
+      /* Fall through.  */
     case BFD_RELOC_16:
     case BFD_RELOC_16_PCREL:
     case BFD_RELOC_LO16:
@@ -2707,7 +2702,7 @@ md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
 
 
 int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
 {
   switch (c)
     {
@@ -2725,24 +2720,28 @@ md_parse_option (int c, char *arg)
 
     case 'b':
       as_warn (_("Option -b is depreciated, please use -mbig"));
+      /* Fall through.  */
     case OPTION_BIG:             /* big model */
       tic4x_big_model = 1;
       break;
 
     case 'p':
       as_warn (_("Option -p is depreciated, please use -mmemparm"));
+      /* Fall through.  */
     case OPTION_MEMPARM:         /* push args */
       tic4x_reg_args = 0;
       break;
 
     case 'r':
       as_warn (_("Option -r is depreciated, please use -mregparm"));
+      /* Fall through.  */
     case OPTION_REGPARM:        /* register args */
       tic4x_reg_args = 1;
       break;
 
     case 's':
       as_warn (_("Option -s is depreciated, please use -msmall"));
+      /* Fall through.  */
     case OPTION_SMALL:         /* small model */
       tic4x_big_model = 0;
       break;
@@ -3015,9 +3014,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixP)
 {
   arelent *reloc;
 
-  reloc = (arelent *) xmalloc (sizeof (arelent));
+  reloc = XNEW (arelent);
 
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
   reloc->address /= OCTETS_PER_BYTE;
This page took 0.029293 seconds and 4 git commands to generate.