gas: enable PC-relative diff relocations on sparc64
[deliverable/binutils-gdb.git] / gas / config / tc-score.c
index 72597a0fac68884248b9fbb7b9e27a37551e1e9c..5e50a8d0165de7614601c615961a928d7e8a77b2 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-score.c -- Assembler for Score
-   Copyright (C) 2006-2014 Free Software Foundation, Inc.
+   Copyright (C) 2006-2017 Free Software Foundation, Inc.
    Contributed by:
    Brain.lin (brain.lin@sunplusct.com)
    Mei Ligang (ligang@sunnorth.com.cn)
@@ -61,7 +61,7 @@ static void s3_assemble (char *str);
 static void s3_operand (expressionS *);
 static void s3_begin (void);
 static void s3_number_to_chars (char *buf, valueT val, int n);
-static char *s3_atof (int type, char *litP, int *sizeP);
+static const char *s3_atof (int type, char *litP, int *sizeP);
 static void s3_frag_check (fragS * fragp ATTRIBUTE_UNUSED);
 static void s3_validate_fix (fixS *fixP);
 static int s3_force_relocation (struct fix *fixp);
@@ -334,7 +334,7 @@ enum s3_insn_type_for_dependency
 
 struct s3_insn_to_dependency
 {
-  char *insn_name;
+  const char *insn_name;
   enum s3_insn_type_for_dependency type;
 };
 
@@ -351,13 +351,13 @@ struct s3_data_dependency
 
 static const struct s3_insn_to_dependency s3_insn_to_dependency_table[] =
 {
-  /* move spectial instruction.  */
+  /* move special instruction.  */
   {"mtcr",      s3_D_mtcr},
 };
 
 static const struct s3_data_dependency s3_data_dependency_table[] =
 {
-  /* Status regiser.  */
+  /* Status register.  */
   {s3_D_mtcr, "cr0", s3_D_all_insn, "", 5, 1, 0},
 };
 
@@ -1071,7 +1071,7 @@ s3_reg_required_here (char **str, int shift, enum s3_score_reg_type reg_type)
         {
           if ((reg == 1) && (s3_nor1 == 1) && (s3_inst.bwarn == 0))
             {
-              as_warn (_("Using temp register(r1)"));
+              as_warn (_("Using temp register (r1)"));
               s3_inst.bwarn = 1;
             }
         }
@@ -2079,7 +2079,7 @@ s3_reglow_required_here (char **str, int shift)
 
   /* Restore the start point, we may have got a reg of the wrong class.  */
   *str = start;
-  sprintf (buff, _("low register(r0-r15)expected, not '%.100s'"), start);
+  sprintf (buff, _("low register (r0-r15) expected, not '%.100s'"), start);
   s3_inst.error = buff;
   return (int) s3_FAIL;
 }
@@ -2344,7 +2344,7 @@ s3_handle_dependency (struct s3_score_it *theinst)
              if (remainder_bubbles <= 2)
                {
                  if (s3_warn_fix_data_dependency)
-                   as_warn (_("Fix data dependency: %s %s -- %s %s  (insert %d nop!/%d)"),
+                   as_warn (_("Fix data dependency: %s %s -- %s %s (insert %d nop!/%d)"),
                             s3_dependency_vector[i].name, s3_dependency_vector[i].reg,
                             s3_dependency_vector[0].name, s3_dependency_vector[0].reg,
                             remainder_bubbles, bubbles);
@@ -2363,7 +2363,7 @@ s3_handle_dependency (struct s3_score_it *theinst)
              else
                {
                  if (s3_warn_fix_data_dependency)
-                   as_warn (_("Fix data dependency: %s %s -- %s %s  (insert 1 pflush/%d)"),
+                   as_warn (_("Fix data dependency: %s %s -- %s %s (insert 1 pflush/%d)"),
                             s3_dependency_vector[i].name, s3_dependency_vector[i].reg,
                             s3_dependency_vector[0].name, s3_dependency_vector[0].reg,
                             bubbles);
@@ -2379,14 +2379,14 @@ s3_handle_dependency (struct s3_score_it *theinst)
             {
              if (warn_or_error)
                {
-                  as_bad (_("data dependency: %s %s -- %s %s  (%d/%d bubble)"),
+                  as_bad (_("data dependency: %s %s -- %s %s (%d/%d bubble)"),
                          s3_dependency_vector[i].name, s3_dependency_vector[i].reg,
                          s3_dependency_vector[0].name, s3_dependency_vector[0].reg,
                          remainder_bubbles, bubbles);
                }
              else
                {
-                  as_warn (_("data dependency: %s %s -- %s %s  (%d/%d bubble)"),
+                  as_warn (_("data dependency: %s %s -- %s %s (%d/%d bubble)"),
                            s3_dependency_vector[i].name, s3_dependency_vector[i].reg,
                            s3_dependency_vector[0].name, s3_dependency_vector[0].reg,
                            remainder_bubbles, bubbles);
@@ -2595,7 +2595,7 @@ s3_gen_insn_frag (struct s3_score_it *part_1, struct s3_score_it *part_2)
   /* Here, we must call frag_grow in order to keep the instruction frag type is
      rs_machine_dependent.
      For, frag_var may change frag_now->fr_type to rs_fill by calling frag_grow which
-     acturally will call frag_wane.
+     actually will call frag_wane.
      Calling frag_grow first will create a new frag_now which free size is 20 that is enough
      for frag_var.  */
   frag_grow (20);
@@ -3775,7 +3775,7 @@ s3_do16_rpush (char *str)
     return;
 
   /* 0: indicate 32.
-     1: invalide value.
+     1: invalid value.
      2: to 31: normal value.  */
   val = s3_inst.instruction & 0x1f;
   if (val == 1)
@@ -3803,7 +3803,7 @@ s3_do16_rpop (char *str)
     return;
 
   /* 0: indicate 32.
-     1: invalide value.
+     1: invalid value.
      2: to 31: normal value.  */
   val = s3_inst.instruction & 0x1f;
   if (val == 1)
@@ -4167,7 +4167,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
 
       /* Var part
         For a local symbol: ldis r1, HI%<constant>
-         but, if lo is outof 16 bit, make hi plus 1  */
+         but, if lo is out of 16 bit, make hi plus 1  */
       if ((lo < -0x8000) || (lo > 0x7fff))
        {
          hi += 1;
@@ -5228,7 +5228,7 @@ s3_do_branch (char *str)
   else if (!(s3_inst.reloc.exp.X_add_number >= -524288
             && s3_inst.reloc.exp.X_add_number <= 524287))
     {
-      s3_inst.error = _("invalid constant: 20 bit expression not in range -2^19..2^19");
+      s3_inst.error = _("invalid constant: 20 bit expression not in range -2^19..2^19-1");
       return;
     }
 
@@ -5362,7 +5362,7 @@ s3_parse_pce_inst (char *insnstr)
         || ((pec_part_1.size == s3_INSN_SIZE) && (s3_inst.size == s3_INSN16_SIZE))
         || ((pec_part_1.size == s3_INSN16_SIZE) && (s3_inst.size == s3_INSN_SIZE)))
     {
-      s3_inst.error = _("pce instruction error (16 bit || 16 bit)'");
+      s3_inst.error = _("pce instruction error (16 bit || 16 bit).");
       sprintf (s3_inst.str, "%s", insnstr);
       return;
     }
@@ -5619,10 +5619,9 @@ s3_get_symbol (void)
   char *name;
   symbolS *p;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
+  c = get_symbol_name (&name);
   p = (symbolS *) symbol_find_or_make (name);
-  *input_line_pointer = c;
+  (void) restore_line_pointer (c);
   return p;
 }
 
@@ -6095,10 +6094,9 @@ s3_s_score_lcomm (int bytes_p)
   segT bss_seg = bss_section;
   int needs_align = 0;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
+  c = get_symbol_name (&name);
   p = input_line_pointer;
-  *p = c;
+  (void) restore_line_pointer (c);
 
   if (name == p)
     {
@@ -6275,8 +6273,8 @@ s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
 {
   int i = 0;
   int len = strlen (r->name) + 2;
-  char *buf = xmalloc (len);
-  char *buf2 = xmalloc (len);
+  char *buf = XNEWVEC (char, len);
+  char *buf2 = XNEWVEC (char, len);
 
   strcpy (buf + i, r->name);
   for (i = 0; buf[i]; i++)
@@ -6346,14 +6344,15 @@ s3_build_dependency_insn_hsh (void)
       const struct s3_insn_to_dependency *tmp = s3_insn_to_dependency_table + i;
       size_t len = strlen (tmp->insn_name);
       struct s3_insn_to_dependency *new_i2n;
+      char *buf;
 
       new_i2n = (struct s3_insn_to_dependency *)
        obstack_alloc (&dependency_obstack,
                       sizeof (struct s3_insn_to_dependency));
-      new_i2n->insn_name = (char *) obstack_alloc (&dependency_obstack,
-                                                   len + 1);
+      buf = (char *) obstack_alloc (&dependency_obstack, len + 1);
 
-      strcpy (new_i2n->insn_name, tmp->insn_name);
+      strcpy (buf, tmp->insn_name);
+      new_i2n->insn_name = buf;
       new_i2n->type = tmp->type;
       hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name,
                    (void *) new_i2n);
@@ -6658,7 +6657,7 @@ s3_md_chars_to_number (char *buf, int n)
   return result;
 }
 
-static char *
+static const char *
 s3_atof (int type, char *litP, int *sizeP)
 {
   int prec;
@@ -6807,7 +6806,7 @@ s3_judge_size_before_relax (fragS * fragp, asection *sec)
   if (change == 1)
     {
       /* Only at the first time determining whether s3_GP instruction relax should be done,
-         return the difference between insntruction size and instruction relax size.  */
+         return the difference between instruction size and instruction relax size.  */
       if (fragp->fr_opcode == NULL)
        {
          fragp->fr_fix = s3_RELAX_NEW (fragp->fr_subtype);
@@ -6915,7 +6914,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp)
 
   value = offset + symbol_address - frag_addr;
   /* change the order of judging rule is because
-     1.not defined symbol or common sysbol or external symbol will change
+     1.not defined symbol or common symbol or external symbol will change
      bcmp to cmp!+beq/bne ,here need to record fragp->fr_opcode
      2.if the flow is as before : it will results to recursive loop
   */
@@ -6924,7 +6923,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp)
       /* Have already relaxed!  Just return 0 to terminate the loop.  */
       return 0;
     }
-  /* need to translate when extern or not defind or common sysbol */
+  /* need to translate when extern or not defined or common symbol */
   else if ((relaxable_p
            && (!((value & 0xfffffe00) == 0 || (value & 0xfffffe00) == 0xfffffe00))
            && fragp->fr_fix == 4
@@ -7091,7 +7090,7 @@ static valueT
 s3_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
 {
   int align = bfd_get_section_alignment (stdoutput, segment);
-  return ((size + (1 << align) - 1) & (-1 << align));
+  return ((size + (1 << align) - 1) & -(1 << align));
 }
 
 static void
@@ -7195,7 +7194,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfffffe00) != 0 && (value & 0xfffffe00) != 0xfffffe00)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                            _(" branch relocation truncate (0x%x) [-2^9 ~ 2^9]"), (unsigned int)value);
+                            _(" branch relocation truncate (0x%x) [-2^9 ~ 2^9-1]"), (unsigned int) value);
               return;
             }
           content = s3_md_chars_to_number (buf, s3_INSN16_SIZE);
@@ -7210,7 +7209,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfff80000) != 0 && (value & 0xfff80000) != 0xfff80000)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19]"), (unsigned int)value);
+                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19-1]"), (unsigned int) value);
               return;
             }
           content = s3_md_chars_to_number (buf, s3_INSN_SIZE);
@@ -7239,7 +7238,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfff80000) != 0 && (value & 0xfff80000) != 0xfff80000)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19]"), (unsigned int)value);
+                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19-1]"), (unsigned int) value);
               return;
             }
           content = s3_md_chars_to_number (buf, s3_INSN_SIZE);
@@ -7251,7 +7250,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
         }
       else
         {
-          /* In differnt section.  */
+          /* In different section.  */
           if ((S_GET_SEGMENT (fixP->fx_addsy) != seg) ||
               (fixP->fx_addsy != NULL && S_IS_EXTERNAL (fixP->fx_addsy)))
             value = fixP->fx_offset;
@@ -7261,7 +7260,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfffffe00) != 0 && (value & 0xfffffe00) != 0xfffffe00)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                            _(" branch relocation truncate (0x%x)  [-2^9 ~ 2^9]"), (unsigned int)value);
+                            _(" branch relocation truncate (0x%x) [-2^9 ~ 2^9-1]"), (unsigned int) value);
               return;
             }
 
@@ -7291,7 +7290,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfff80000) != 0 && (value & 0xfff80000) != 0xfff80000)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19]"), (unsigned int)value);
+                            _(" branch relocation truncate (0x%x) [-2^19 ~ 2^19-1]"), (unsigned int) value);
               return;
             }
 
@@ -7316,7 +7315,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           if ((value & 0xfffffe00) != 0 && (value & 0xfffffe00) != 0xfffffe00)
             {
               as_bad_where (fixP->fx_file, fixP->fx_line,
-                           _(" branch relocation truncate (0x%x)  [-2^9 ~ 2^9]"), (unsigned int)value);
+                           _(" branch relocation truncate (0x%x)  [-2^9 ~ 2^9-1]"), (unsigned int) value);
               return;
             }
 
@@ -7399,12 +7398,12 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
   static arelent *retval[MAX_RELOC_EXPANSION + 1];  /* MAX_RELOC_EXPANSION equals 2.  */
   arelent *reloc;
   bfd_reloc_code_real_type code;
-  char *type;
+  const char *type;
 
-  reloc = retval[0] = xmalloc (sizeof (arelent));
+  reloc = retval[0] = XNEW (arelent);
   retval[1] = NULL;
 
-  reloc->sym_ptr_ptr = 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->addend = fixp->fx_offset;
@@ -7432,9 +7431,9 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
       newval |= (((off >> 14) & 0x3) << 16);
       s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
 
-      retval[1] = xmalloc (sizeof (arelent));
+      retval[1] = XNEW (arelent);
       retval[2] = NULL;
-      retval[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+      retval[1]->sym_ptr_ptr = XNEW (asymbol *);
       *retval[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       retval[1]->address = (reloc->address + s3_RELAX_RELOC2 (fixp->fx_frag->fr_subtype));
 
@@ -7454,6 +7453,7 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
           code = BFD_RELOC_32_PCREL;
           break;
         }
+      /* Fall through.  */
     case BFD_RELOC_HI16_S:
     case BFD_RELOC_LO16:
     case BFD_RELOC_SCORE_JMP:
@@ -7543,7 +7543,7 @@ md_number_to_chars (char *buf, valueT val, int n)
    within the words.  For example, (double) 1.1 in big endian mode is
    the byte sequence 3f f1 99 99 99 99 99 9a, and in little endian mode is
    the byte sequence 99 99 f1 3f 9a 99 99 99.  */
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   if (score3)
@@ -7717,7 +7717,7 @@ score_set_mach (const char *arg)
 }
 
 int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
 {
   switch (c)
     {
@@ -7808,29 +7808,29 @@ md_show_usage (FILE * fp)
 #endif
 
   fprintf (fp, _("\
-        -FIXDD\t\tassemble code for fix data dependency\n"));
+        -FIXDD\t\tfix data dependencies\n"));
   fprintf (fp, _("\
-        -NWARN\t\tassemble code for no warning message for fix data dependency\n"));
+        -NWARN\t\tdo not print warning message when fixing data dependencies\n"));
   fprintf (fp, _("\
-        -SCORE5\t\tassemble code for target is SCORE5\n"));
+        -SCORE5\t\tassemble code for target SCORE5\n"));
   fprintf (fp, _("\
-        -SCORE5U\tassemble code for target is SCORE5U\n"));
+        -SCORE5U\tassemble code for target SCORE5U\n"));
   fprintf (fp, _("\
-        -SCORE7\t\tassemble code for target is SCORE7, this is default setting\n"));
+        -SCORE7\t\tassemble code for target SCORE7 [default]\n"));
   fprintf (fp, _("\
-        -SCORE3\t\tassemble code for target is SCORE3\n"));
+        -SCORE3\t\tassemble code for target SCORE3\n"));
   fprintf (fp, _("\
-        -march=score7\tassemble code for target is SCORE7, this is default setting\n"));
+        -march=score7\tassemble code for target SCORE7 [default]\n"));
   fprintf (fp, _("\
-        -march=score3\tassemble code for target is SCORE3\n"));
+        -march=score3\tassemble code for target SCORE3\n"));
   fprintf (fp, _("\
         -USE_R1\t\tassemble code for no warning message when using temp register r1\n"));
   fprintf (fp, _("\
-        -KPIC\t\tassemble code for PIC\n"));
+        -KPIC\t\tgenerate PIC\n"));
   fprintf (fp, _("\
-        -O0\t\tassembler will not perform any optimizations\n"));
+        -O0\t\tdo not perform any optimizations\n"));
   fprintf (fp, _("\
-        -G gpnum\tassemble code for setting gpsize and default is 8 byte\n"));
+        -G gpnum\tassemble code for setting gpsize, default is 8 bytes\n"));
   fprintf (fp, _("\
-        -V \t\tSunplus release version \n"));
+        -V \t\tSunplus release version\n"));
 }
This page took 0.030961 seconds and 4 git commands to generate.