]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-score.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / tc-score.c
index 7456d3894aeb0439324bf4b490b03432d15de194..b48fd7a5d8ad7cb1e64a6800a2585859a9dd5932 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-score.c -- Assembler for Score
-   Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2006-2021 Free Software Foundation, Inc.
    Contributed by:
    Brain.lin (brain.lin@sunplusct.com)
    Mei Ligang (ligang@sunnorth.com.cn)
@@ -58,10 +58,10 @@ static void s_score_lcomm (int bytes_p);
 static void s3_md_number_to_chars (char *buf, valueT val, int n);
 static valueT s3_md_chars_to_number (char *buf, int n);
 static void s3_assemble (char *str);
-static void s3_operand (expressionS * expr);
+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);
@@ -130,8 +130,8 @@ static void s3_do16_cmpi (char *);
 static void s3_do16_rdi5 (char *);
 static void s3_do16_xi5 (char *);
 static void s3_do16_ldst_insn (char *);
-static void s3_do16_slli_srli(char *);
-static void s3_do16_ldiu(char *);
+static void s3_do16_slli_srli (char *);
+static void s3_do16_ldiu (char *);
 static void s3_do16_push_pop (char *);
 static void s3_do16_rpush (char *);
 static void s3_do16_rpop (char *);
@@ -300,7 +300,6 @@ size_t md_longopts_size = sizeof (md_longopts);
                              ? s3_INSN16_SIZE : (s3_GET_INSN_CLASS (type) == INSN_CLASS_48) \
                                              ? s3_INSN48_SIZE : s3_INSN_SIZE)
 
-#define s3_MAX_LITTLENUMS 6
 #define s3_INSN_NAME_LEN 16
 
 /* Relax will need some padding for alignment.  */
@@ -334,7 +333,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 +350,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},
 };
 
@@ -460,7 +459,7 @@ struct s3_reg_map
 {
   const struct s3_reg_entry *names;
   int max_regno;
-  struct hash_control *htab;
+  htab_t htab;
   const char *expected;
 };
 
@@ -471,8 +470,8 @@ static struct s3_reg_map s3_all_reg_maps[] =
   {s3_score_crn_table, 31, NULL, N_("S+core co-processor register expected")},
 };
 
-static struct hash_control *s3_score_ops_hsh = NULL;
-static struct hash_control *s3_dependency_insn_hsh = NULL;
+static htab_t s3_score_ops_hsh = NULL;
+static htab_t s3_dependency_insn_hsh = NULL;
 
 
 struct s3_datafield_range
@@ -531,15 +530,15 @@ static struct s3_datafield_range s3_score_df_range[] =
   {_IMM16_pic,        16, {0, (1 << 16) - 1}},         /* (     0 ~ 65535) */
   {_SIMM5,            5,  {-(1 << 4), (1 << 4) - 1}},  /* (   -16 ~ 15   ) */
   {_SIMM6,            6,  {-(1 << 5), (1 << 5) - 1}},  /* (   -32 ~ 31   ) */
-  {_IMM32,            32, {0, 0xfffffff}},        
-  {_SIMM32,           32, {-0x80000000, 0x7fffffff}},  
-  {_IMM11,            11, {0, (1 << 11) - 1}},         
+  {_IMM32,            32, {0, 0xfffffff}},
+  {_SIMM32,           32, {-0x80000000, 0x7fffffff}},
+  {_IMM11,            11, {0, (1 << 11) - 1}},
 };
 
 struct s3_asm_opcode
 {
   /* Instruction name.  */
-  const char *template;
+  const char *template_name;
 
   /* Instruction Opcode.  */
   bfd_vma value;
@@ -557,7 +556,7 @@ struct s3_asm_opcode
   void (*parms) (char *);
 };
 
-static const struct s3_asm_opcode s3_score_ldst_insns[] = 
+static const struct s3_asm_opcode s3_score_ldst_insns[] =
 {
   {"lw",        0x20000000, 0x3e000000, 0x1000,     Rd_rvalueRs_SI15,     s3_do_ldst_insn},
   {"lw",        0x06000000, 0x3e000007, 0x8000,     Rd_rvalueRs_preSI12,  s3_do_ldst_insn},
@@ -585,7 +584,7 @@ static const struct s3_asm_opcode s3_score_ldst_insns[] =
   {"sb",        0x0e000007, 0x3e000007, 0x8000,     Rd_lvalueRs_postSI12, s3_do_ldst_insn},
 };
 
-static const struct s3_asm_opcode s3_score_insns[] = 
+static const struct s3_asm_opcode s3_score_insns[] =
 {
   {"abs",       0x3800000a, 0x3e007fff, 0x8000,     Rd_Rs_x,              s3_do_dsp3},
   {"abs.s",     0x3800004b, 0x3e007fff, 0x8000,     Rd_Rs_x,              s3_do_dsp3},
@@ -691,7 +690,7 @@ static const struct s3_asm_opcode s3_score_insns[] =
   {"brccl",     0x00000409, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
   {"brgtul",    0x00000809, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
   {"brleul",    0x00000c09, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
-  {"breql",     0x00001009, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs}, 
+  {"breql",     0x00001009, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
   {"brnel",     0x00001409, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
   {"brgtl",     0x00001809, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
   {"brlel",     0x00001c09, 0x3e007fff, 0x8000,     x_Rs_x,               s3_do_rs},
@@ -749,8 +748,8 @@ static const struct s3_asm_opcode s3_score_insns[] =
   /* s3_inst.relax */
   {"ldi",       0x020c0000, 0x3e0e0000, 0x6400,     Rd_SI16,              s3_do_rdsi16},
   {"ldis",      0x0a0c0000, 0x3e0e0000, 0x8000,     Rd_I16,               s3_do_ldis},
-  /* ldi <-> ldiu!.  */  
+
+  /* ldi <-> ldiu!.  */
   {"ldiu!",     0x6400,     0x7c00,     0x8000,     Rd_I5,                s3_do16_ldiu},
 
   /*ltbb! , ltbh! ltbw! */
@@ -954,9 +953,9 @@ static const struct s3_asm_opcode s3_score_insns[] =
   {"li",        0x020c0000, 0x3e0e0000, 0x8000,     Insn_Type_SYN,        s3_do_macro_li_rdi32},
 
   /* la reg, imm32        -->(1)  ldi  reg, simm16
-                             (2)  ldis reg, %HI(imm32)        
-                                  ori  reg, %LO(imm32) 
-          
+                             (2)  ldis reg, %HI(imm32)
+                                  ori  reg, %LO(imm32)
+
      la reg, symbol       -->(1)  lis  reg, %HI(imm32)
                                   ori  reg, %LO(imm32)  */
   {"la",        0x020c0000, 0x3e0e0000, 0x8000,     Insn_Type_SYN,        s3_do_macro_la_rdi32},
@@ -1028,7 +1027,7 @@ s3_end_of_line (char *str)
 }
 
 static int
-s3_score_reg_parse (char **ccp, struct hash_control *htab)
+s3_score_reg_parse (char **ccp, htab_t htab)
 {
   char *start = *ccp;
   char c;
@@ -1045,7 +1044,7 @@ s3_score_reg_parse (char **ccp, struct hash_control *htab)
     c = *p++;
 
   *--p = 0;
-  reg = (struct s3_reg_entry *) hash_find (htab, start);
+  reg = (struct s3_reg_entry *) str_hash_find (htab, start);
   *p = c;
 
   if (reg)
@@ -1071,7 +1070,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;
             }
         }
@@ -1143,7 +1142,7 @@ s3_do_rdrsrs (char *str)
     {
       /* Check mulr, mulur rd is even number.  */
       if (((s3_inst.instruction & 0x3e0003ff) == 0x00000340
-            || (s3_inst.instruction & 0x3e0003ff) == 0x00000342)
+          || (s3_inst.instruction & 0x3e0003ff) == 0x00000342)
           && (reg % 2))
         {
           s3_inst.error = _("rd must be even number.");
@@ -1176,7 +1175,7 @@ s3_walk_no_bignums (symbolS * sp)
   if (symbol_get_value_expression (sp)->X_add_symbol)
     return (s3_walk_no_bignums (symbol_get_value_expression (sp)->X_add_symbol)
            || (symbol_get_value_expression (sp)->X_op_symbol
-               && s3_walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol)));  
+               && s3_walk_no_bignums (symbol_get_value_expression (sp)->X_op_symbol)));
 
   return 0;
 }
@@ -1185,12 +1184,11 @@ static int
 s3_my_get_expression (expressionS * ep, char **str)
 {
   char *save_in;
-  segT seg;
 
   save_in = input_line_pointer;
   input_line_pointer = *str;
   s3_in_my_get_expression = 1;
-  seg = expression (ep);
+  (void) expression (ep);
   s3_in_my_get_expression = 0;
 
   if (ep->X_op == O_illegal)
@@ -1305,18 +1303,12 @@ s3_validate_immediate (bfd_signed_vma val, unsigned int data_type, int hex_p)
 
     case _IMM5_MULTI_LOAD:
       if (val >= 2 && val <= 32)
-        {       
+        {
           if (val == 32)
-            {       
-              val = 0;
-            }       
+           val = 0;
           return val;
-        }       
-      else    
-        {       
-          return (int) s3_FAIL;
-        }       
-      break;  
+        }
+      return (int) s3_FAIL;
 
     case _IMM32:
       if (val >= 0 && val <= 0xffffffff)
@@ -1393,10 +1385,10 @@ s3_data_op2 (char **str, int shift, enum score_data_type data_type)
         }
       dataptr = (char *)data_exp;
 
-      if ((dataptr != NULL) 
+      if ((dataptr != NULL)
           && (((strstr (dataptr, "0x")) != NULL)
               || ((strstr (dataptr, "0X")) != NULL)))
-        { 
+        {
           hex_p = 1;
           if ((data_type != _SIMM16_LA)
               && (data_type != _VALUE_HI16)
@@ -1431,9 +1423,9 @@ s3_data_op2 (char **str, int shift, enum score_data_type data_type)
           && (s3_inst.type != Rd_lvalueRs_SI15)
           && (s3_inst.type != Insn_internal)
           && (((*dataptr >= 'a') && (*dataptr <= 'z'))
-             || ((*dataptr == '0') && (*(dataptr + 1) == 'x') && (*(dataptr + 2) != '0'))
-             || ((*dataptr == '+') && (*(dataptr + 1) != '0'))
-             || ((*dataptr == '-') && (*(dataptr + 1) != '0'))))
+             || ((*dataptr == '0') && (*(dataptr + 1) == 'x') && (*(dataptr + 2) != '0'))
+             || ((*dataptr == '+') && (*(dataptr + 1) != '0'))
+             || ((*dataptr == '-') && (*(dataptr + 1) != '0'))))
         {
           s3_inst.error = s3_BAD_ARGS;
           return (int) s3_FAIL;
@@ -1600,7 +1592,9 @@ s3_do_rdsi16 (char *str)
   else  if ((s3_inst.instruction & 0x02040001) == 0x02040001)
     {
       /*  imm <=0x3f  (5 bit<<1)*/
-      if (((s3_inst.instruction & 0x1ffe0)==0)||(((s3_inst.instruction & 0x1ffe0) == 0x1ffe0)&&(s3_inst.instruction & 0x003e) !=0))
+      if (((s3_inst.instruction & 0x1ffe0) == 0)
+         || (((s3_inst.instruction & 0x1ffe0) == 0x1ffe0)
+             && (s3_inst.instruction & 0x003e) != 0))
         {
           s3_inst.relax_inst |= (s3_inst.instruction >> 1) & 0x1f;
           s3_inst.relax_inst |= (((s3_inst.instruction >> 20) & 0x1f) << 5);
@@ -1613,11 +1607,13 @@ s3_do_rdsi16 (char *str)
         }
     }
   /* addi */
-  else  if (((s3_inst.instruction & 0x2000000) == 0x02000000)&& (s3_inst.relax_inst!=0x8000))
+  else  if (((s3_inst.instruction & 0x2000000) == 0x02000000) && (s3_inst.relax_inst!=0x8000))
     {
       /* rd : 0-16 ; imm <=0x7f  (6 bit<<1)*/
-      if ((((s3_inst.instruction >> 20) & 0x10) != 0x10) && 
-      (((s3_inst.instruction & 0x1ffc0)==0)||(((s3_inst.instruction & 0x1ffc0) == 0x1ffc0)&&(s3_inst.instruction & 0x007e) !=0)))
+      if ((((s3_inst.instruction >> 20) & 0x10) != 0x10)
+         && (((s3_inst.instruction & 0x1ffc0) == 0)
+             || (((s3_inst.instruction & 0x1ffc0) == 0x1ffc0)
+                 && (s3_inst.instruction & 0x007e) != 0)))
         {
           s3_inst.relax_inst |= (s3_inst.instruction >> 1) & 0x3f;
           s3_inst.relax_inst |= (((s3_inst.instruction >> 20) & 0xf) << 6);
@@ -1626,7 +1622,6 @@ s3_do_rdsi16 (char *str)
       else
         {
           s3_inst.relax_inst =0x8000;
-
         }
     }
 
@@ -1702,7 +1697,7 @@ s3_do_sub_rdrssi14 (char *str)     /* -(2^13)~((2^13)-1) */
 /* Handle bitclr.c/bitset.c/bittgl.c/slli.c/srai.c/srli.c/roli.c/rori.c/rolic.c.
    0~((2^14)-1) */
 static void
-s3_do_rdrsi5 (char *str) 
+s3_do_rdrsi5 (char *str)
 {
   s3_skip_whitespace (str);
 
@@ -1796,7 +1791,7 @@ s3_do_rdi16 (char *str)
       /* rd : 0-16 ;imm =0 -> can transform to addi!*/
       if ((((s3_inst.instruction >> 20) & 0x10) != 0x10) && ((s3_inst.instruction & 0x1ffff)==0))
         {
-         s3_inst.relax_inst =0x5c00; /* addi! */
+         s3_inst.relax_inst =0x5c00; /* addi! */
           s3_inst.relax_inst |= (s3_inst.instruction >> 1) & 0x3f;
           s3_inst.relax_inst |= (((s3_inst.instruction >> 20) & 0xf) << 6);
           s3_inst.relax_size = 2;
@@ -1915,7 +1910,7 @@ s3_do_xi5x (char *str)
 
   if (s3_inst.relax_inst != 0x8000)
     {
-      s3_inst.relax_inst |= ((s3_inst.instruction >> 15) & 0x1f) ;
+      s3_inst.relax_inst |= ((s3_inst.instruction >> 15) & 0x1f);
       s3_inst.relax_size = 2;
     }
 }
@@ -1937,8 +1932,7 @@ s3_do_rdrs (char *str)
         {
           /* mv! rd : 5bit , ra : 5bit */
           s3_inst.relax_inst |= ((s3_inst.instruction >> 15) & 0x1f)  | (((s3_inst.instruction >> 20) & 0x1f) << 5);
-          s3_inst.relax_size = 2;   
-         
+          s3_inst.relax_size = 2;
         }
       else if ((((s3_inst.instruction >> 15) & 0x10) == 0x0) && (((s3_inst.instruction >> 20) & 0x10) == 0))
         {
@@ -2084,7 +2078,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;
 }
@@ -2209,7 +2203,8 @@ s3_dependency_type_from_insn (char *insn_name)
   const struct s3_insn_to_dependency *tmp;
 
   strcpy (name, insn_name);
-  tmp = (const struct s3_insn_to_dependency *) hash_find (s3_dependency_insn_hsh, name);
+  tmp = (const struct s3_insn_to_dependency *)
+    str_hash_find (s3_dependency_insn_hsh, name);
 
   if (tmp)
     return tmp->type;
@@ -2219,7 +2214,7 @@ s3_dependency_type_from_insn (char *insn_name)
 
 static int
 s3_check_dependency (char *pre_insn, char *pre_reg,
-                  char *cur_insn, char *cur_reg, int *warn_or_error)
+                    char *cur_insn, char *cur_reg, int *warn_or_error)
 {
   int bubbles = 0;
   unsigned int i;
@@ -2277,7 +2272,7 @@ s3_build_one_frag (struct s3_score_it one_inst)
 
   p = frag_var (rs_machine_dependent, relax_size + s3_RELAX_PAD_BYTE, 0,
                 s3_RELAX_ENCODE (one_inst.size, one_inst.relax_size,
-                              one_inst.type, 0, 0, relaxable_p),
+                                one_inst.type, 0, 0, relaxable_p),
                 NULL, 0, NULL);
 
   if (relaxable_p)
@@ -2337,7 +2332,7 @@ s3_handle_dependency (struct s3_score_it *theinst)
       strcpy (pre_insn, s3_dependency_vector[i].name);
 
       bubbles = s3_check_dependency (pre_insn, s3_dependency_vector[i].reg,
-                                  cur_insn, s3_dependency_vector[0].reg, &warn_or_error);
+                                    cur_insn, s3_dependency_vector[0].reg, &warn_or_error);
       remainder_bubbles = bubbles - i + 1;
 
       if (remainder_bubbles > 0)
@@ -2349,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);
@@ -2368,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);
@@ -2384,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)"),
-                           s3_dependency_vector[i].name, s3_dependency_vector[i].reg,
-                           s3_dependency_vector[0].name, s3_dependency_vector[0].reg,
-                           remainder_bubbles, bubbles);
+                  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);
@@ -2490,7 +2485,7 @@ s3_get_insn_class_from_type (enum score_insn_type type)
    32-bit instruction: 1, 0.
    16-bit instruction: 0.  */
 static bfd_vma
-s3_adjust_paritybit (bfd_vma m_code, enum insn_class class)
+s3_adjust_paritybit (bfd_vma m_code, enum insn_class i_class)
 {
   bfd_vma result = 0;
   bfd_vma m_code_high = 0;
@@ -2500,7 +2495,7 @@ s3_adjust_paritybit (bfd_vma m_code, enum insn_class class)
   unsigned long pb_middle = 0;
   unsigned long pb_low = 0;
 
-  if (class == INSN_CLASS_48)
+  if (i_class == INSN_CLASS_48)
     {
       pb_high = 0x800000000000LL;
       pb_middle = 0x80000000;
@@ -2509,10 +2504,10 @@ s3_adjust_paritybit (bfd_vma m_code, enum insn_class class)
       m_code_middle = m_code & 0x3fff8000;
       m_code_low = m_code & 0x00007fff;
       result = pb_high | (m_code_high << 2) |
-               pb_middle | (m_code_middle << 1) |
-               pb_low | m_code_low;
+       pb_middle | (m_code_middle << 1) |
+       pb_low | m_code_low;
     }
-  else if (class == INSN_CLASS_32 || class == INSN_CLASS_SYN)
+  else if (i_class == INSN_CLASS_32 || i_class == INSN_CLASS_SYN)
     {
       pb_high = 0x80000000;
       pb_low = 0x00000000;
@@ -2520,7 +2515,7 @@ s3_adjust_paritybit (bfd_vma m_code, enum insn_class class)
       m_code_low = m_code & 0x00007fff;
       result = pb_high | (m_code_high << 1) | pb_low | m_code_low;
     }
-  else if (class == INSN_CLASS_16)
+  else if (i_class == INSN_CLASS_16)
     {
       pb_high = 0;
       pb_low = 0;
@@ -2528,7 +2523,7 @@ s3_adjust_paritybit (bfd_vma m_code, enum insn_class class)
       m_code_low = m_code & 0x00007fff;
       result = pb_high | (m_code_high << 1) | pb_low | m_code_low;
     }
-  else if (class == INSN_CLASS_PCE)
+  else if (i_class == INSN_CLASS_PCE)
     {
       /* Keep original.  */
       pb_high = 0;
@@ -2563,7 +2558,7 @@ s3_gen_insn_frag (struct s3_score_it *part_1, struct s3_score_it *part_2)
   if (pce_p)
     {
       backup_inst1.instruction = ((backup_inst1.instruction & 0x7FFF) << 15)
-                                  | (inst2->instruction & 0x7FFF);
+       | (inst2->instruction & 0x7FFF);
       backup_inst1.instruction = s3_adjust_paritybit (backup_inst1.instruction, INSN_CLASS_PCE);
       backup_inst1.relax_inst = 0x8000;
       backup_inst1.size = s3_INSN_SIZE;
@@ -2573,7 +2568,7 @@ s3_gen_insn_frag (struct s3_score_it *part_1, struct s3_score_it *part_2)
   else
     {
       backup_inst1.instruction = s3_adjust_paritybit (backup_inst1.instruction,
-                                                  s3_GET_INSN_CLASS (backup_inst1.type));
+                                                     s3_GET_INSN_CLASS (backup_inst1.type));
     }
 
   if (backup_inst1.relax_size != 0)
@@ -2600,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);
@@ -2617,19 +2612,19 @@ s3_gen_insn_frag (struct s3_score_it *part_1, struct s3_score_it *part_2)
     {
       if (inst1->reloc.type != BFD_RELOC_NONE)
        s3_fix_new_score (frag_now, p - frag_now->fr_literal,
-                      inst1->size, &inst1->reloc.exp,
-                      inst1->reloc.pc_rel, inst1->reloc.type);
+                         inst1->size, &inst1->reloc.exp,
+                         inst1->reloc.pc_rel, inst1->reloc.type);
 
       if (inst2->reloc.type != BFD_RELOC_NONE)
        s3_fix_new_score (frag_now, p - frag_now->fr_literal + 2,
-                      inst2->size, &inst2->reloc.exp, inst2->reloc.pc_rel, inst2->reloc.type);
+                         inst2->size, &inst2->reloc.exp, inst2->reloc.pc_rel, inst2->reloc.type);
     }
   else
     {
       if (backup_inst1.reloc.type != BFD_RELOC_NONE)
        s3_fix_new_score (frag_now, p - frag_now->fr_literal,
-                      backup_inst1.size, &backup_inst1.reloc.exp,
-                      backup_inst1.reloc.pc_rel, backup_inst1.reloc.type);
+                         backup_inst1.size, &backup_inst1.reloc.exp,
+                         backup_inst1.reloc.pc_rel, backup_inst1.reloc.type);
     }
 
   /* relax_size may be 2, 4, 12 or 0, 0 indicates no relaxation.  */
@@ -2638,7 +2633,7 @@ s3_gen_insn_frag (struct s3_score_it *part_1, struct s3_score_it *part_2)
 
   p = frag_var (rs_machine_dependent, relax_size + s3_RELAX_PAD_BYTE, 0,
                 s3_RELAX_ENCODE (backup_inst1.size, backup_inst1.relax_size,
-                              backup_inst1.type, 0, 0, relaxable_p),
+                                backup_inst1.type, 0, 0, relaxable_p),
                 backup_inst1.reloc.exp.X_add_symbol, 0, NULL);
 
   if (relaxable_p)
@@ -2668,7 +2663,8 @@ s3_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p)
   c = *p;
   *p = '\0';
 
-  opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator);
+  opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+                                                        operator);
   *p = c;
 
   memset (&s3_inst, '\0', sizeof (s3_inst));
@@ -2681,7 +2677,7 @@ s3_parse_16_32_inst (char *insnstr, bfd_boolean gen_frag_p)
       s3_inst.size = s3_GET_INSN_SIZE (s3_inst.type);
       s3_inst.relax_size = 0;
       s3_inst.bwarn = 0;
-      sprintf (s3_inst.name, "%s", opcode->template);
+      sprintf (s3_inst.name, "%s", opcode->template_name);
       strcpy (s3_inst.reg, "");
       s3_inst.error = NULL;
       s3_inst.reloc.type = BFD_RELOC_NONE;
@@ -2714,7 +2710,8 @@ s3_parse_48_inst (char *insnstr, bfd_boolean gen_frag_p)
   c = *p;
   *p = '\0';
 
-  opcode = (const struct s3_asm_opcode *) hash_find (s3_score_ops_hsh, operator);
+  opcode = (const struct s3_asm_opcode *) str_hash_find (s3_score_ops_hsh,
+                                                        operator);
   *p = c;
 
   memset (&s3_inst, '\0', sizeof (s3_inst));
@@ -2727,7 +2724,7 @@ s3_parse_48_inst (char *insnstr, bfd_boolean gen_frag_p)
       s3_inst.size = s3_GET_INSN_SIZE (s3_inst.type);
       s3_inst.relax_size = 0;
       s3_inst.bwarn = 0;
-      sprintf (s3_inst.name, "%s", opcode->template);
+      sprintf (s3_inst.name, "%s", opcode->template_name);
       strcpy (s3_inst.reg, "");
       s3_inst.error = NULL;
       s3_inst.reloc.type = BFD_RELOC_NONE;
@@ -2940,12 +2937,10 @@ s3_do_ldst_insn (char *str)
   int conflict_reg;
   int value;
   char * temp;
-  char *strbak;
   char *dataptr;
   int reg;
   int ldst_idx = 0;
 
-  strbak = str;
   s3_skip_whitespace (str);
 
   if (((conflict_reg = s3_reg_required_here (&str, 20, s3_REG_TYPE_SCORE)) == (int) s3_FAIL)
@@ -3075,9 +3070,9 @@ s3_do_ldst_insn (char *str)
 
               /* lw/lh/lbu/sw/sh/sb, offset = 0, relax to 16 bit instruction.  */
               /* if ((ldst_idx == INSN_LBU)
-                  || (ldst_idx == INSN_LH)
-                  || (ldst_idx == INSN_LW)
-                  || (ldst_idx == INSN_SB) || (ldst_idx == INSN_SH) || (ldst_idx == INSN_SW))*/
+                || (ldst_idx == INSN_LH)
+                || (ldst_idx == INSN_LW)
+                || (ldst_idx == INSN_SB) || (ldst_idx == INSN_SH) || (ldst_idx == INSN_SW))*/
               if ( (ldst_idx == INSN_LW)|| (ldst_idx == INSN_SW))
                 {
                   /* ra only 3 bit , rd only 4 bit for lw! and sw! */
@@ -3138,7 +3133,6 @@ s3_do_ldst_insn (char *str)
 
           if (s3_inst.reloc.exp.X_op == O_constant)
             {
-              int value;
               unsigned int data_type;
 
               if (pre_inc == 1)
@@ -3411,8 +3405,7 @@ s3_do_ldst_cop (char *str)
 static void
 s3_do16_ldst_insn (char *str)
 {
-  int conflict_reg=0;
-  char * temp;
+  int conflict_reg = 0;
   s3_skip_whitespace (str);
 
   if ((s3_reglow_required_here (&str, 8) == (int) s3_FAIL) || (s3_skip_past_comma (&str) == (int) s3_FAIL))
@@ -3429,12 +3422,12 @@ s3_do16_ldst_insn (char *str)
       if (conflict_reg&0x8)
         {
           sprintf (s3_err_msg,  _("invalid register number: %d is not in [r0--r7]"),conflict_reg);
-          s3_inst.error=s3_err_msg;
-          return ;
+          s3_inst.error = s3_err_msg;
+          return;
         }
 
       s3_skip_whitespace (str);
-      temp = str + 1;    /* The latter will process decimal/hex expression.  */
+
       if (*str == ']')
         {
           str++;
@@ -3465,33 +3458,32 @@ s3_do16_ldst_insn (char *str)
               data_type = _IMM5_RSHIFT_2;
               value = s3_validate_immediate (s3_inst.reloc.exp.X_add_number, data_type, 0);
               if (value == (int) s3_FAIL)
-              {
-               if (data_type < 30)
-                 sprintf (s3_err_msg,
-                   _("invalid constant: %d bit expression not in range %d..%d"),
-                   s3_score_df_range[data_type].bits,
-                   s3_score_df_range[data_type].range[0], s3_score_df_range[data_type].range[1]);
+               {
+                 if (data_type < 30)
+                   sprintf (s3_err_msg,
+                            _("invalid constant: %d bit expression not in range %d..%d"),
+                            s3_score_df_range[data_type].bits,
+                            s3_score_df_range[data_type].range[0], s3_score_df_range[data_type].range[1]);
                   s3_inst.error = s3_err_msg;
                  return;
                }
-              if (value &0x3)
+              if (value & 0x3)
                 {
                   sprintf (s3_err_msg,  _("invalid constant: %d is not word align integer"),value);
-                  s3_inst.error=s3_err_msg;
-                  return ;
+                  s3_inst.error = s3_err_msg;
+                  return;
                 }
 
-              value >>=2;
+              value >>= 2;
               s3_inst.instruction |= value;
             }
         }
-   
     }
   else
     {
       sprintf (s3_err_msg,  _("missing ["));
-      s3_inst.error=s3_err_msg;
-      return ;
+      s3_inst.error = s3_err_msg;
+      return;
     }
 }
 
@@ -3649,7 +3641,7 @@ s3_do_or48 (char *str)
     return;
 }
 
-static void 
+static void
 s3_do_mbitclr (char *str)
 {
   int val;
@@ -3658,7 +3650,7 @@ s3_do_mbitclr (char *str)
   if (*str != '[')
     {
       sprintf (s3_err_msg,  _("missing ["));
-      s3_inst.error=s3_err_msg;
+      s3_inst.error = s3_err_msg;
       return;
     }
   str++;
@@ -3679,7 +3671,7 @@ s3_do_mbitclr (char *str)
   if (*str != ']')
     {
       sprintf (s3_err_msg,  _("missing ]"));
-      s3_inst.error=s3_err_msg;
+      s3_inst.error = s3_err_msg;
       return;
     }
   str++;
@@ -3690,11 +3682,11 @@ s3_do_mbitclr (char *str)
 
   /* Set imm11 to opcode.  */
   s3_inst.instruction |= (val & 0x1)
-                      | (((val >> 1 ) & 0x7) << 7)
-                      | (((val >> 4 ) & 0x1f) << 20);
+    | (((val >> 1 ) & 0x7) << 7)
+    | (((val >> 4 ) & 0x1f) << 20);
 }
 
-static void 
+static void
 s3_do_mbitset (char *str)
 {
   int val;
@@ -3703,7 +3695,7 @@ s3_do_mbitset (char *str)
   if (*str != '[')
     {
       sprintf (s3_err_msg,  _("missing ["));
-      s3_inst.error=s3_err_msg;
+      s3_inst.error = s3_err_msg;
       return;
     }
   str++;
@@ -3724,7 +3716,7 @@ s3_do_mbitset (char *str)
   if (*str != ']')
     {
       sprintf (s3_err_msg,  _("missing ]"));
-      s3_inst.error=s3_err_msg;
+      s3_inst.error = s3_err_msg;
       return;
     }
   str++;
@@ -3735,8 +3727,8 @@ s3_do_mbitset (char *str)
 
   /* Set imm11 to opcode.  */
   s3_inst.instruction |= (val & 0x1)
-                      | (((val >> 1 ) & 0x7) << 7)
-                      | (((val >> 4 ) & 0x1f) << 20);
+    | (((val >> 1 ) & 0x7) << 7)
+    | (((val >> 4 ) & 0x1f) << 20);
 }
 
 static void
@@ -3747,7 +3739,7 @@ s3_do16_slli_srli (char *str)
   if ((s3_reglow_required_here (&str, 5) == (int) s3_FAIL)
       || (s3_skip_past_comma (&str) == (int) s3_FAIL)
       || s3_data_op2 (&str, 0, _IMM5) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL) 
+      || s3_end_of_line (str) == (int) s3_FAIL)
     return;
 }
 
@@ -3759,7 +3751,7 @@ s3_do16_ldiu (char *str)
   if ((s3_reg_required_here (&str, 5,s3_REG_TYPE_SCORE) == (int) s3_FAIL)
       || (s3_skip_past_comma (&str) == (int) s3_FAIL)
       || s3_data_op2 (&str, 0, _IMM5) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL) 
+      || s3_end_of_line (str) == (int) s3_FAIL)
     return;
 }
 
@@ -3768,7 +3760,7 @@ s3_do16_push_pop (char *str)
 {
   s3_skip_whitespace (str);
   if ((s3_reg_required_here (&str, 0, s3_REG_TYPE_SCORE)) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL) 
+      || s3_end_of_line (str) == (int) s3_FAIL)
     return;
 }
 
@@ -3781,17 +3773,17 @@ s3_do16_rpush (char *str)
   if ((reg = (s3_reg_required_here (&str, 5, s3_REG_TYPE_SCORE))) == (int) s3_FAIL
       || s3_skip_past_comma (&str) == (int) s3_FAIL
       || s3_data_op2 (&str, 0, _IMM5_MULTI_LOAD) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL) 
+      || s3_end_of_line (str) == (int) s3_FAIL)
     return;
 
   /* 0: indicate 32.
-     1: invalide value.
+     1: invalid value.
      2: to 31: normal value.  */
-  val = s3_inst.instruction & 0x1f; 
+  val = s3_inst.instruction & 0x1f;
   if (val == 1)
     {
-      s3_inst.error = _("imm5 should >= 2"); 
-      return; 
+      s3_inst.error = _("imm5 should >= 2");
+      return;
     }
   if (reg >= 32)
     {
@@ -3809,11 +3801,11 @@ s3_do16_rpop (char *str)
   if ((reg = (s3_reg_required_here (&str, 5, s3_REG_TYPE_SCORE))) == (int) s3_FAIL
       || s3_skip_past_comma (&str) == (int) s3_FAIL
       || s3_data_op2 (&str, 0, _IMM5_MULTI_LOAD) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL) 
+      || s3_end_of_line (str) == (int) s3_FAIL)
     return;
 
   /* 0: indicate 32.
-     1: invalide value.
+     1: invalid value.
      2: to 31: normal value.  */
   val = s3_inst.instruction & 0x1f;
   if (val == 1)
@@ -3827,7 +3819,7 @@ s3_do16_rpop (char *str)
       s3_inst.error = _("reg should <= 31");
       return;
     }
-  else 
+  else
     {
       if ((reg + val) <= 32)
         reg = reg + val - 1;
@@ -3985,8 +3977,8 @@ s3_do_ldst_atomic (char *str)
 
 static void
 s3_build_relax_frag (struct s3_score_it fix_insts[s3_RELAX_INST_NUM], int fix_num ATTRIBUTE_UNUSED,
-                  struct s3_score_it var_insts[s3_RELAX_INST_NUM], int var_num,
-                  symbolS *add_symbol)
+                    struct s3_score_it var_insts[s3_RELAX_INST_NUM], int var_num,
+                    symbolS *add_symbol)
 {
   int i;
   char *p;
@@ -4005,7 +3997,7 @@ s3_build_relax_frag (struct s3_score_it fix_insts[s3_RELAX_INST_NUM], int fix_nu
     {
       inst_main.relax_size += var_insts[i].size;
       var_insts[i].instruction = s3_adjust_paritybit (var_insts[i].instruction,
-                                                   s3_GET_INSN_CLASS (var_insts[i].type));
+                                                     s3_GET_INSN_CLASS (var_insts[i].type));
     }
 
   /* Check data dependency.  */
@@ -4028,7 +4020,7 @@ s3_build_relax_frag (struct s3_score_it fix_insts[s3_RELAX_INST_NUM], int fix_nu
 
   if (inst_main.reloc.type != BFD_RELOC_NONE)
     fixp = s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
-                         &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
+                            &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
 
   frag_now->tc_frag_data.fixp = fixp;
   cur_fixp = frag_now->tc_frag_data.fixp;
@@ -4046,8 +4038,8 @@ s3_build_relax_frag (struct s3_score_it fix_insts[s3_RELAX_INST_NUM], int fix_nu
       if (var_insts[i].reloc.type != BFD_RELOC_NONE)
         {
           fixp = s3_fix_new_score (frag_now, where, var_insts[i].size,
-                                &var_insts[i].reloc.exp, var_insts[i].reloc.pc_rel,
-                                var_insts[i].reloc.type);
+                                  &var_insts[i].reloc.exp, var_insts[i].reloc.pc_rel,
+                                  var_insts[i].reloc.type);
           if (fixp)
             {
               if (cur_fixp)
@@ -4066,7 +4058,7 @@ s3_build_relax_frag (struct s3_score_it fix_insts[s3_RELAX_INST_NUM], int fix_nu
 
   p = frag_var (rs_machine_dependent, inst_main.relax_size + s3_RELAX_PAD_BYTE, 0,
                 s3_RELAX_ENCODE (inst_main.size, inst_main.relax_size, inst_main.type,
-                0, inst_main.size, 0), add_symbol, 0, NULL);
+                                0, inst_main.size, 0), add_symbol, 0, NULL);
 
   /* Write fr_var part.
      no calling s3_gen_insn_frag, no fixS will be generated.  */
@@ -4101,12 +4093,12 @@ s3_build_la_pic (int reg_rd, expressionS exp)
       fix_num = 1;
       var_num = 2;
 
-      /* For an external symbol, only one insn is generated; 
+      /* For an external symbol, only one insn is generated;
          For a local symbol, two insns are generated.  */
       /* Fix part
          For an external symbol: lw rD, <sym>($gp)
-                                 (BFD_RELOC_SCORE_GOT15 or BFD_RELOC_SCORE_CALL15)  */
-      sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
+        (BFD_RELOC_SCORE_GOT15 or BFD_RELOC_SCORE_CALL15)  */
+      sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
        return;
 
@@ -4120,7 +4112,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
         addi rD, <sym>       (BFD_RELOC_GOT_LO16) */
       s3_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
       memcpy (&var_insts[0], &s3_inst, sizeof (struct s3_score_it));
-      sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, add_symbol->bsym->name);
+      sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
        return;
 
@@ -4130,7 +4122,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
   else if (add_number >= -0x8000 && add_number <= 0x7fff)
     {
       /* Insn 1: lw rD, <sym>($gp)    (BFD_RELOC_SCORE_GOT15)  */
-      sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
+      sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, TRUE) == (int) s3_FAIL)
        return;
 
@@ -4147,7 +4139,8 @@ s3_build_la_pic (int reg_rd, expressionS exp)
 
       /* Var part
         For a local symbol: addi rD, <sym>+<constant>    (BFD_RELOC_GOT_LO16)  */
-      sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd, add_symbol->bsym->name, (int)add_number);
+      sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd,
+              S_GET_NAME (add_symbol), (int) add_number);
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
        return;
 
@@ -4160,7 +4153,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
       int lo = add_number & 0x0000FFFF;
 
       /* Insn 1: lw rD, <sym>($gp)    (BFD_RELOC_SCORE_GOT15)  */
-      sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
+      sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, TRUE) == (int) s3_FAIL)
        return;
 
@@ -4177,7 +4170,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;
@@ -4202,7 +4195,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
 
       /* Var part
         For a local symbol: addi r1, <sym>+LO%<constant>    (BFD_RELOC_GOT_LO16)  */
-      sprintf (tmp, "addi_u_pic r1, %s + %d", add_symbol->bsym->name, lo);
+      sprintf (tmp, "addi_u_pic r1, %s + %d", S_GET_NAME (add_symbol), lo);
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
        return;
 
@@ -4214,8 +4207,8 @@ s3_build_la_pic (int reg_rd, expressionS exp)
       if (s3_append_insn (tmp, TRUE) == (int) s3_FAIL)
        return;
 
-     /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
-     s3_inst.bwarn = -1;
+      /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
+      s3_inst.bwarn = -1;
     }
 
   s3_nor1 = r1_bak;
@@ -4489,103 +4482,105 @@ s3_exp_macro_ldst_abs (char *str)
 
   s3_nor1 = r1_bak;
 }
+
 /* Handle bcmpeq / bcmpne  */
 static void
 s3_do_macro_bcmp (char *str)
 {
   int reg_a , reg_b;
-  char keep_data[s3_MAX_LITERAL_POOL_SIZE];
-  char* ptemp;
-  int i=0;
+  char *keep_data;
+  size_t keep_data_size;
+  int i;
   struct s3_score_it inst_expand[2];
   struct s3_score_it inst_main;
 
-
+  memset (inst_expand, 0, sizeof inst_expand);
   s3_skip_whitespace (str);
   if (( reg_a = s3_reg_required_here (&str, 15, s3_REG_TYPE_SCORE)) == (int) s3_FAIL
       || s3_skip_past_comma (&str) == (int) s3_FAIL
       ||(reg_b = s3_reg_required_here (&str, 10, s3_REG_TYPE_SCORE)) == (int) s3_FAIL
       || s3_skip_past_comma (&str) == (int) s3_FAIL)
-      return;
-  ptemp =str;
-  while(*ptemp!=0)
-  {
-       keep_data[i]=*ptemp;
-       i++;
-       ptemp++;
-  }
-  keep_data[i]=0;
-  if (s3_my_get_expression (&s3_inst.reloc.exp, &str) == (int) s3_FAIL 
-      ||reg_b ==0
+    return;
+
+  keep_data_size = strlen (str) + 1;
+  keep_data = xmalloc (keep_data_size * 2 + 14);
+  memcpy (keep_data, str, keep_data_size);
+
+  if (s3_my_get_expression (&s3_inst.reloc.exp, &str) == (int) s3_FAIL
+      ||reg_b == 0
       || s3_end_of_line (str) == (int) s3_FAIL)
-    return ; 
+    goto out;
   else if (s3_inst.reloc.exp.X_add_symbol == 0)
     {
       s3_inst.error = _("lacking label  ");
-      return;
+      goto out;
     }
   else
     {
-      char append_str[s3_MAX_LITERAL_POOL_SIZE];      
+      char *append_str = keep_data + keep_data_size;
       s3_SET_INSN_ERROR (NULL);
-      
+
       s3_inst.reloc.type = BFD_RELOC_SCORE_BCMP;
       s3_inst.reloc.pc_rel = 1;
       bfd_signed_vma val = s3_inst.reloc.exp.X_add_number;
 
       /* Branch 32  offset field : 20 bit, 16 bit branch offset field : 8 bit.  */
-      s3_inst.instruction |= ((s3_inst.reloc.exp.X_add_number>>1) & 0x1) | ((s3_inst.reloc.exp.X_add_number>>2) & 0x7)<<7 |((s3_inst.reloc.exp.X_add_number>>5) & 0x1f)<<20; 
+      s3_inst.instruction |= ((s3_inst.reloc.exp.X_add_number >> 1) & 0x1)
+       | ((s3_inst.reloc.exp.X_add_number >> 2) & 0x7) << 7
+       | ((s3_inst.reloc.exp.X_add_number >> 5) & 0x1f) << 20;
 
       /* Check and set offset.  */
       if (((val & 0xfffffe00) != 0)
-           && ((val & 0xfffffe00) != 0xfffffe00))
+         && ((val & 0xfffffe00) != 0xfffffe00))
         {
           /* support bcmp --> cmp!+beq (bne) */
           if (s3_score_pic == s3_NO_PIC)
             {
-              sprintf (&append_str[0], "cmp! r%d, r%d", reg_a, reg_b);
-              if (s3_append_insn (&append_str[0], TRUE) == (int) s3_FAIL)
-                return;
-              if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
-                sprintf (&append_str[1], "beq %s", keep_data);
-              else
-                sprintf (&append_str[1], "bne %s", keep_data);
-              if (s3_append_insn (&append_str[1], TRUE) == (int) s3_FAIL)
-                return;
-              }
-            else
-              {
-                gas_assert (s3_inst.reloc.exp.X_add_symbol);
-              }
-            /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
-            s3_inst.bwarn = -1;
-            return;
+             sprintf (append_str, "cmp! r%d, r%d", reg_a, reg_b);
+             if (s3_append_insn (append_str, TRUE) == (int) s3_FAIL)
+               goto out;
+             if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
+               memcpy (append_str, "beq ", 4);
+             else
+               memcpy (append_str, "bne ", 4);
+             memmove (append_str + 4, keep_data, strlen (keep_data) + 1);
+             if (s3_append_insn (append_str, TRUE) == (int) s3_FAIL)
+               goto out;
+           }
+         else
+           {
+             gas_assert (s3_inst.reloc.exp.X_add_symbol);
+           }
+         /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
+         s3_inst.bwarn = -1;
+         goto out;
         }
       else
         {
           val >>= 1;
           s3_inst.instruction |= (val & 0x1)
-                              | (((val >> 1) & 0x7) << 7)
-                              | (((val >> 4) & 0x1f) << 20);
+           | (((val >> 1) & 0x7) << 7)
+           | (((val >> 4) & 0x1f) << 20);
         }
 
       /* Backup s3_inst.  */
       memcpy (&inst_main, &s3_inst, sizeof (struct s3_score_it));
 
-      if (s3_score_pic == s3_NO_PIC) 
+      if (s3_score_pic == s3_NO_PIC)
         {
-          sprintf (&append_str[0], "cmp! r%d, r%d", reg_a, reg_b);
-          if (s3_append_insn (&append_str[0], FALSE) == (int) s3_FAIL)
-            return;
-          memcpy (&inst_expand[0], &s3_inst, sizeof (struct s3_score_it));
-  
-          if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
-            sprintf (&append_str[1], "beq %s", keep_data);
-          else
-            sprintf (&append_str[1], "bne %s", keep_data);
-          if (s3_append_insn (&append_str[1], FALSE) == (int) s3_FAIL)
-            return;
-          memcpy (&inst_expand[1], &s3_inst, sizeof (struct s3_score_it));
+         sprintf (append_str, "cmp! r%d, r%d", reg_a, reg_b);
+         if (s3_append_insn (append_str, FALSE) == (int) s3_FAIL)
+           goto out;
+         memcpy (&inst_expand[0], &s3_inst, sizeof (struct s3_score_it));
+
+         if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
+           memcpy (append_str, "beq ", 4);
+         else
+           memcpy (append_str, "bne ", 4);
+         memmove (append_str + 4, keep_data, strlen (keep_data) + 1);
+         if (s3_append_insn (append_str, FALSE) == (int) s3_FAIL)
+           goto out;
+         memcpy (&inst_expand[1], &s3_inst, sizeof (struct s3_score_it));
         }
       else
         {
@@ -4598,17 +4593,17 @@ s3_do_macro_bcmp (char *str)
       inst_main.instruction = s3_adjust_paritybit (inst_main.instruction, s3_GET_INSN_CLASS (inst_main.type));
 
       for (i = 0; i < 2; i++)
-        inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction, 
+        inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction,
                                                           s3_GET_INSN_CLASS (inst_expand[i].type));
       /* Check data dependency.  */
       s3_handle_dependency (&inst_main);
       /* Start a new frag if frag_now is not empty.  */
       if (frag_now_fix () != 0)
-      {
-       if (!frag_now->tc_frag_data.is_insn)
-         frag_wane (frag_now);
-       frag_new (0);
-      }
+       {
+         if (!frag_now->tc_frag_data.is_insn)
+           frag_wane (frag_now);
+         frag_new (0);
+       }
       frag_grow (20);
 
       /* Write fr_fix part.  */
@@ -4617,10 +4612,10 @@ s3_do_macro_bcmp (char *str)
       s3_md_number_to_chars (p, inst_main.instruction, inst_main.size);
 
       if (inst_main.reloc.type != BFD_RELOC_NONE)
-      {
-       s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
-                          &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
-      }
+       {
+         s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
+                           &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
+       }
 #ifdef OBJ_ELF
       dwarf2_emit_insn (inst_main.size);
 #endif
@@ -4640,67 +4635,67 @@ s3_do_macro_bcmp (char *str)
 
       /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
       s3_inst.bwarn = -1;
-     }
+    }
+ out:
+  free (keep_data);
 }
 
 /* Handle bcmpeqz / bcmpnez  */
 static void
 s3_do_macro_bcmpz (char *str)
 {
-  int reg_a ;
-  char keep_data[s3_MAX_LITERAL_POOL_SIZE];
-  char* ptemp;
-  int i=0;
+  int reg_a;
+  char *keep_data;
+  size_t keep_data_size;
+  int i;
   struct s3_score_it inst_expand[2];
   struct s3_score_it inst_main;
 
+  memset (inst_expand, 0, sizeof inst_expand);
   s3_skip_whitespace (str);
   if (( reg_a = s3_reg_required_here (&str, 15, s3_REG_TYPE_SCORE)) == (int) s3_FAIL
-      || s3_skip_past_comma (&str) == (int) s3_FAIL   )
+      || s3_skip_past_comma (&str) == (int) s3_FAIL)
     return;
-  ptemp =str;
-  while(*ptemp!=0)
-  {
-       keep_data[i]=*ptemp;
-       i++;
-       ptemp++;
-  }
-  keep_data[i]=0;
-  if ( s3_my_get_expression (&s3_inst.reloc.exp, &str) == (int) s3_FAIL 
-      || s3_end_of_line (str) == (int) s3_FAIL)
-    return ;
 
+  keep_data_size = strlen (str) + 1;
+  keep_data = xmalloc (keep_data_size * 2 + 13);
+  memcpy (keep_data, str, keep_data_size);
+
+  if (s3_my_get_expression (&s3_inst.reloc.exp, &str) == (int) s3_FAIL
+      || s3_end_of_line (str) == (int) s3_FAIL)
+    goto out;
   else if (s3_inst.reloc.exp.X_add_symbol == 0)
     {
       s3_inst.error = _("lacking label  ");
-      return;
+      goto out;
     }
   else
     {
-      char append_str[s3_MAX_LITERAL_POOL_SIZE];      
+      char *append_str = keep_data + keep_data_size;
       s3_SET_INSN_ERROR (NULL);
       s3_inst.reloc.type = BFD_RELOC_SCORE_BCMP;
-      s3_inst.reloc.pc_rel = 1;    
+      s3_inst.reloc.pc_rel = 1;
       bfd_signed_vma val = s3_inst.reloc.exp.X_add_number;
 
       /* Branch 32  offset field : 20 bit, 16 bit branch offset field : 8 bit.  */
-      s3_inst.instruction |= ((s3_inst.reloc.exp.X_add_number>>1) & 0x1) | ((s3_inst.reloc.exp.X_add_number>>2) & 0x7)<<7 |((s3_inst.reloc.exp.X_add_number>>5) & 0x1f)<<20; 
+      s3_inst.instruction |= ((s3_inst.reloc.exp.X_add_number>>1) & 0x1) | ((s3_inst.reloc.exp.X_add_number>>2) & 0x7)<<7 |((s3_inst.reloc.exp.X_add_number>>5) & 0x1f)<<20;
 
       /* Check and set offset.  */
       if (((val & 0xfffffe00) != 0)
-           && ((val & 0xfffffe00) != 0xfffffe00))
+         && ((val & 0xfffffe00) != 0xfffffe00))
         {
           if (s3_score_pic == s3_NO_PIC)
             {
-              sprintf (&append_str[0], "cmpi! r%d,0", reg_a);
-              if (s3_append_insn (&append_str[0], TRUE) == (int) s3_FAIL)
-                return;
-              if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
-                sprintf (&append_str[1], "beq %s", keep_data);
-              else
-                sprintf (&append_str[1], "bne %s", keep_data);
-              if (s3_append_insn (&append_str[1], TRUE) == (int) s3_FAIL)
-                return;
+             sprintf (append_str, "cmpi! r%d, 0", reg_a);
+             if (s3_append_insn (append_str, TRUE) == (int) s3_FAIL)
+               goto out;
+             if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
+               memcpy (append_str, "beq ", 4);
+             else
+               memcpy (append_str, "bne ", 4);
+             memmove (append_str + 4, keep_data, strlen (keep_data) + 1);
+             if (s3_append_insn (append_str, TRUE) == (int) s3_FAIL)
+               goto out;
             }
           else
             {
@@ -4708,32 +4703,33 @@ s3_do_macro_bcmpz (char *str)
             }
           /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
           s3_inst.bwarn = -1;
-          return;
+         goto out;
         }
       else
         {
           val >>= 1;
           s3_inst.instruction |= (val & 0x1)
-                              | (((val >> 1) & 0x7) << 7)
-                              | (((val >> 4) & 0x1f) << 20);
+           | (((val >> 1) & 0x7) << 7)
+           | (((val >> 4) & 0x1f) << 20);
         }
 
       /* Backup s3_inst.  */
       memcpy (&inst_main, &s3_inst, sizeof (struct s3_score_it));
-      
-      if (s3_score_pic == s3_NO_PIC) 
+
+      if (s3_score_pic == s3_NO_PIC)
         {
-          sprintf (&append_str[0], "cmpi! r%d, 0", reg_a);
-          if (s3_append_insn (&append_str[0], FALSE) == (int) s3_FAIL)
-            return;
-          memcpy (&inst_expand[0], &s3_inst, sizeof (struct s3_score_it));
-          if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
-            sprintf (&append_str[1], "beq %s", keep_data);
-          else
-            sprintf (&append_str[1], "bne %s", keep_data);
-          if (s3_append_insn (&append_str[1], FALSE) == (int) s3_FAIL)
-            return;
-          memcpy (&inst_expand[1], &s3_inst, sizeof (struct s3_score_it));
+         sprintf (append_str, "cmpi! r%d, 0", reg_a);
+         if (s3_append_insn (append_str, FALSE) == (int) s3_FAIL)
+           goto out;
+         memcpy (&inst_expand[0], &s3_inst, sizeof (struct s3_score_it));
+         if ((inst_main.instruction & 0x3e00007e) == 0x0000004c)
+           memcpy (append_str, "beq ", 4);
+         else
+           memcpy (append_str, "bne ", 4);
+         memmove (append_str + 4, keep_data, strlen (keep_data) + 1);
+         if (s3_append_insn (append_str, FALSE) == (int) s3_FAIL)
+           goto out;
+         memcpy (&inst_expand[1], &s3_inst, sizeof (struct s3_score_it));
         }
       else
         {
@@ -4746,16 +4742,17 @@ s3_do_macro_bcmpz (char *str)
       inst_main.instruction = s3_adjust_paritybit (inst_main.instruction, s3_GET_INSN_CLASS (inst_main.type));
 
       for (i = 0; i < 2; i++)
-        inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction , s3_GET_INSN_CLASS (inst_expand[i].type));
+        inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction ,
+                                                         s3_GET_INSN_CLASS (inst_expand[i].type));
       /* Check data dependency.  */
       s3_handle_dependency (&inst_main);
       /* Start a new frag if frag_now is not empty.  */
       if (frag_now_fix () != 0)
-      {
-       if (!frag_now->tc_frag_data.is_insn)
-         frag_wane (frag_now);
-       frag_new (0);
-      }
+       {
+         if (!frag_now->tc_frag_data.is_insn)
+           frag_wane (frag_now);
+         frag_new (0);
+       }
       frag_grow (20);
 
       /* Write fr_fix part.  */
@@ -4764,10 +4761,10 @@ s3_do_macro_bcmpz (char *str)
       s3_md_number_to_chars (p, inst_main.instruction, inst_main.size);
 
       if (inst_main.reloc.type != BFD_RELOC_NONE)
-      {
-       s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
-                          &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
-      }
+       {
+         s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
+                           &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
+       }
 #ifdef OBJ_ELF
       dwarf2_emit_insn (inst_main.size);
 #endif
@@ -4787,7 +4784,9 @@ s3_do_macro_bcmpz (char *str)
 
       /* Set bwarn as -1, so macro instruction itself will not be generated frag.  */
       s3_inst.bwarn = -1;
-     }
+    }
+ out:
+  free (keep_data);
 }
 
 static int
@@ -4820,12 +4819,12 @@ s3_nopic_need_relax (symbolS * sym, int before_relaxing)
           return 1;
         }
       else if ((!S_IS_DEFINED (sym) || S_IS_COMMON (sym)) && (0
-      /* We must defer this decision until after the whole file has been read,
-         since there might be a .extern after the first use of this symbol.  */
-               || (before_relaxing
-                   && S_GET_VALUE (sym) == 0)
-               || (S_GET_VALUE (sym) != 0
-                   && S_GET_VALUE (sym) <= s3_g_switch_value)))
+                                                             /* We must defer this decision until after the whole file has been read,
+                                                                since there might be a .extern after the first use of this symbol.  */
+                                                             || (before_relaxing
+                                                                 && S_GET_VALUE (sym) == 0)
+                                                             || (S_GET_VALUE (sym) != 0
+                                                                 && S_GET_VALUE (sym) <= s3_g_switch_value)))
         {
           return 0;
         }
@@ -4867,8 +4866,8 @@ s3_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
          For a local symbol, three insns are generated.  */
       /* Fix part
          For an external symbol: lw rD, <sym>($gp)
-                                 (BFD_RELOC_SCORE_GOT15)  */
-      sprintf (tmp, "lw_pic r1, %s", add_symbol->bsym->name);
+        (BFD_RELOC_SCORE_GOT15)  */
+      sprintf (tmp, "lw_pic r1, %s", S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
         return;
 
@@ -4880,7 +4879,7 @@ s3_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
         addi rD, <sym>       (BFD_RELOC_GOT_LO16) */
       s3_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
       memcpy (&var_insts[0], &s3_inst, sizeof (struct s3_score_it));
-      sprintf (tmp, "addi_s_pic r1, %s", add_symbol->bsym->name);
+      sprintf (tmp, "addi_s_pic r1, %s", S_GET_NAME (add_symbol));
       if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
         return;
 
@@ -4993,14 +4992,15 @@ s3_do_macro_ldst_label (char *str)
         {
           int ldst_idx = 0;
           ldst_idx = s3_inst.instruction & OPC_PSEUDOLDST_MASK;
-          s3_build_lwst_pic (reg_rd, s3_inst.reloc.exp, s3_score_ldst_insns[ldst_idx * 3 + 0].template);
+          s3_build_lwst_pic (reg_rd, s3_inst.reloc.exp,
+                             s3_score_ldst_insns[ldst_idx * 3 + 0].template_name);
           return;
         }
       else
        {
           if ((s3_inst.reloc.exp.X_add_number <= 0x3fff)
-               && (s3_inst.reloc.exp.X_add_number >= -0x4000)
-               && (!s3_nopic_need_relax (s3_inst.reloc.exp.X_add_symbol, 1)))
+             && (s3_inst.reloc.exp.X_add_number >= -0x4000)
+             && (!s3_nopic_need_relax (s3_inst.reloc.exp.X_add_symbol, 1)))
            {
               int ldst_idx = 0;
 
@@ -5045,9 +5045,9 @@ s3_do_macro_ldst_label (char *str)
       /* Adjust instruction opcode and to be relaxed instruction opcode.  */
       inst_main.instruction = s3_adjust_paritybit (inst_main.instruction, s3_GET_INSN_CLASS (inst_main.type));
 
-      /* relax lw rd, label -> ldis rs, imm16 
-                               ori  rd, imm16
-                               lw rd, [rs, imm15] or lw! rd, [rs, imm5].  */
+      /* relax lw rd, label -> ldis rs, imm16
+        ori  rd, imm16
+        lw rd, [rs, imm15] or lw! rd, [rs, imm5].  */
       if (inst_expand[2].relax_size == 0)
         inst_main.relax_size = inst_expand[0].size + inst_expand[1].size + inst_expand[2].size;
       else
@@ -5056,7 +5056,7 @@ s3_do_macro_ldst_label (char *str)
       inst_main.type = Insn_GP;
 
       for (i = 0; i < 3; i++)
-       inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction, 
+       inst_expand[i].instruction = s3_adjust_paritybit (inst_expand[i].instruction,
                                                           s3_GET_INSN_CLASS (inst_expand[i].type));
 
       /* Check data dependency.  */
@@ -5079,7 +5079,7 @@ s3_do_macro_ldst_label (char *str)
       if (inst_main.reloc.type != BFD_RELOC_NONE)
         {
           s3_fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
-                         &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
+                           &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
         }
 
 #ifdef OBJ_ELF
@@ -5099,9 +5099,9 @@ s3_do_macro_ldst_label (char *str)
       s3_md_number_to_chars (p, inst_expand[1].instruction, inst_expand[1].size);
       p += inst_expand[1].size;
 
-      /* relax lw rd, label -> ldis rs, imm16 
-                               ori  rd, imm16
-                               lw rd, [rs, imm15] or lw! rd, [rs, imm5].  */
+      /* relax lw rd, label -> ldis rs, imm16
+        ori  rd, imm16
+        lw rd, [rs, imm15] or lw! rd, [rs, imm5].  */
       if (inst_expand[2].relax_size == 0)
         s3_md_number_to_chars (p, inst_expand[2].instruction, inst_expand[2].size);
       else
@@ -5202,7 +5202,7 @@ s3_do_jump (char *str)
     }
 
   if (!(s3_inst.reloc.exp.X_add_number >= -16777216
-      && s3_inst.reloc.exp.X_add_number <= 16777215))
+       && s3_inst.reloc.exp.X_add_number <= 16777215))
     {
       s3_inst.error = _("invalid constant: 25 bit expression not in range [-16777216, 16777215]");
       return;
@@ -5229,9 +5229,9 @@ s3_do_branch (char *str)
       return;
     }
   else if (!(s3_inst.reloc.exp.X_add_number >= -524288
-           && s3_inst.reloc.exp.X_add_number <= 524287))
+            && 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;
     }
 
@@ -5258,7 +5258,7 @@ static void
 s3_do16_branch (char *str)
 {
   if ((s3_my_get_expression (&s3_inst.reloc.exp, &str) == (int) s3_FAIL
-      || s3_end_of_line (str) == (int) s3_FAIL))
+       || s3_end_of_line (str) == (int) s3_FAIL))
     {
       ;
     }
@@ -5267,7 +5267,7 @@ s3_do16_branch (char *str)
       s3_inst.error = _("lacking label");
     }
   else if (!(s3_inst.reloc.exp.X_add_number >= -512
-           && s3_inst.reloc.exp.X_add_number <= 511))
+            && s3_inst.reloc.exp.X_add_number <= 511))
     {
       s3_inst.error = _("invalid constant: 10 bit expression not in range [-2^9, 2^9-1]");
     }
@@ -5307,22 +5307,22 @@ s3_pic_need_relax (symbolS *sym, asection *segtype)
   linkonce = FALSE;
   if (symsec != segtype && ! S_IS_LOCAL (sym))
     {
-      if ((bfd_get_section_flags (stdoutput, symsec) & SEC_LINK_ONCE) != 0)
+      if ((bfd_section_flags (symsec) & SEC_LINK_ONCE) != 0)
        linkonce = TRUE;
 
       /* The GNU toolchain uses an extension for ELF: a section
-         beginning with the magic string .gnu.linkonce is a linkonce
-         section.  */
+        beginning with the magic string .gnu.linkonce is a linkonce
+        section.  */
       if (strncmp (segment_name (symsec), ".gnu.linkonce",
                   sizeof ".gnu.linkonce" - 1) == 0)
        linkonce = TRUE;
     }
 
   /* This must duplicate the test in adjust_reloc_syms.  */
-  return (symsec != &bfd_und_section
-           && symsec != &bfd_abs_section
-         && ! bfd_is_com_section (symsec)
-           && !linkonce
+  return (!bfd_is_und_section (symsec)
+         && !bfd_is_abs_section (symsec)
+         && !bfd_is_com_section (symsec)
+         && !linkonce
 #ifdef OBJ_ELF
          /* A global or weak symbol is treated as external.  */
          && (OUTPUT_FLAVOR != bfd_target_elf_flavour
@@ -5362,11 +5362,11 @@ s3_parse_pce_inst (char *insnstr)
     return;
 
   if (   ((pec_part_1.size == s3_INSN_SIZE) && (s3_inst.size == s3_INSN_SIZE))
-      || ((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)))
+        || ((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)'");
-      sprintf (s3_inst.str, insnstr);
+      s3_inst.error = _("pce instruction error (16 bit || 16 bit).");
+      sprintf (s3_inst.str, "%s", insnstr);
       return;
     }
 
@@ -5380,7 +5380,7 @@ s3_do16_dsp (char *str)
 {
   int rd = 0;
 
-  /* Check 3d.  */ 
+  /* Check 3d.  */
   if (s3_score3d == 0)
     {
       s3_inst.error = _("score3d instruction.");
@@ -5404,7 +5404,7 @@ s3_do16_dsp (char *str)
 static void
 s3_do16_dsp2 (char *str)
 {
-  /* Check 3d.  */ 
+  /* Check 3d.  */
   if (s3_score3d == 0)
     {
       s3_inst.error = _("score3d instruction.");
@@ -5431,7 +5431,7 @@ s3_do16_dsp2 (char *str)
 static void
 s3_do_dsp (char *str)
 {
-  /* Check 3d.  */ 
+  /* Check 3d.  */
   if (s3_score3d == 0)
     {
       s3_inst.error = _("score3d instruction.");
@@ -5460,7 +5460,7 @@ s3_do_dsp2 (char *str)
 {
   int reg;
 
-  /* Check 3d.  */ 
+  /* Check 3d.  */
   if (s3_score3d == 0)
     {
       s3_inst.error = _("score3d instruction.");
@@ -5482,7 +5482,7 @@ s3_do_dsp2 (char *str)
     {
       /* Check mulr, mulur rd is even number.  */
       if (((s3_inst.instruction & 0x3e0003ff) == 0x00000340
-            || (s3_inst.instruction & 0x3e0003ff) == 0x00000342)
+          || (s3_inst.instruction & 0x3e0003ff) == 0x00000342)
           && (reg % 2))
         {
           s3_inst.error = _("rd must be even number.");
@@ -5509,7 +5509,7 @@ s3_do_dsp2 (char *str)
 static void
 s3_do_dsp3 (char *str)
 {
-  /* Check 3d.  */ 
+  /* Check 3d.  */
   if (s3_score3d == 0)
     {
       s3_inst.error = _("score3d instruction.");
@@ -5553,7 +5553,7 @@ static void
 s3_score_s_section (int ignore)
 {
   obj_elf_section (ignore);
-  if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
+  if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     record_alignment (now_seg, 2);
 
 }
@@ -5576,14 +5576,16 @@ s3_s_change_sec (int sec)
     {
     case 'r':
       seg = subseg_new (s3_RDATA_SECTION_NAME, (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (stdoutput, seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_RELOC | SEC_DATA));
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+                                  | SEC_RELOC | SEC_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
       break;
     case 's':
       seg = subseg_new (".sdata", (subsegT) get_absolute_expression ());
-      bfd_set_section_flags (stdoutput, seg, SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA);
+      bfd_set_section_flags (seg, (SEC_ALLOC | SEC_LOAD | SEC_RELOC
+                                  | SEC_DATA | SEC_SMALL_DATA));
       if (strcmp (TARGET_OS, "elf") != 0)
         record_alignment (seg, 4);
       demand_empty_rest_of_line ();
@@ -5622,10 +5624,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;
 }
 
@@ -5693,17 +5694,10 @@ s3_s_score_ent (int aent)
   if (ISDIGIT (*input_line_pointer) || *input_line_pointer == '-')
     s3_get_number ();
 
-#ifdef BFD_ASSEMBLER
-  if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
+  if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#endif
   if (!maybe_text)
     as_warn (_(".ent or .aent not in text section."));
   if (!aent && s3_cur_proc_ptr)
@@ -5791,7 +5785,6 @@ s3_s_score_end (int x ATTRIBUTE_UNUSED)
   /* Generate a .pdr section.  */
   segT saved_seg = now_seg;
   subsegT saved_subseg = now_subseg;
-  valueT dot;
   expressionS exp;
   char *fragp;
 
@@ -5803,17 +5796,10 @@ s3_s_score_end (int x ATTRIBUTE_UNUSED)
   else
     p = NULL;
 
-#ifdef BFD_ASSEMBLER
-  if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
-    maybe_text = 1;
-  else
-    maybe_text = 0;
-#else
-  if (now_seg != data_section && now_seg != bss_section)
+  if ((bfd_section_flags (now_seg) & SEC_CODE) != 0)
     maybe_text = 1;
   else
     maybe_text = 0;
-#endif
 
   if (!maybe_text)
     as_warn (_(".end not in text section"));
@@ -5842,7 +5828,7 @@ s3_s_score_end (int x ATTRIBUTE_UNUSED)
 
   else
     {
-      dot = frag_now_fix ();
+      (void) frag_now_fix ();
       gas_assert (s3_pdr_seg);
       subseg_set (s3_pdr_seg, 0);
       /* Write the symbol.  */
@@ -6069,18 +6055,18 @@ s3_s_score_cpadd (int ignore ATTRIBUTE_UNUSED)
 }
 
 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
-#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR)               \
-    do                                                         \
-    {                                                          \
-    if ((SIZE) >= 8)                                           \
-    (P2VAR) = 3;                                               \
-    else if ((SIZE) >= 4)                                      \
-    (P2VAR) = 2;                                               \
-    else if ((SIZE) >= 2)                                      \
-    (P2VAR) = 1;                                               \
-    else                                                       \
-    (P2VAR) = 0;                                               \
-    }                                                          \
+#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR)       \
+  do                                                   \
+    {                                                  \
+      if ((SIZE) >= 8)                                 \
+       (P2VAR) = 3;                                    \
+      else if ((SIZE) >= 4)                            \
+       (P2VAR) = 2;                                    \
+      else if ((SIZE) >= 2)                            \
+       (P2VAR) = 1;                                    \
+      else                                             \
+       (P2VAR) = 0;                                    \
+    }                                                  \
   while (0)
 #endif
 
@@ -6099,10 +6085,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)
     {
@@ -6138,15 +6123,14 @@ s3_s_score_lcomm (int bytes_p)
   if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour || OUTPUT_FLAVOR == bfd_target_elf_flavour)
     {
       /* For Score and Alpha ECOFF or ELF, small objects are put in .sbss.  */
-      if ((unsigned)temp <= bfd_get_gp_size (stdoutput))
-        {
-          bss_seg = subseg_new (".sbss", 1);
-          seg_info (bss_seg)->bss = 1;
-#ifdef BFD_ASSEMBLER
-          if (!bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
-            as_warn (_("error setting flags for \".sbss\": %s"), bfd_errmsg (bfd_get_error ()));
-#endif
-        }
+      if ((unsigned) temp <= bfd_get_gp_size (stdoutput))
+       {
+         bss_seg = subseg_new (".sbss", 1);
+         seg_info (bss_seg)->bss = 1;
+         if (!bfd_set_section_flags (bss_seg, SEC_ALLOC | SEC_SMALL_DATA))
+           as_warn (_("error setting flags for \".sbss\": %s"),
+                    bfd_errmsg (bfd_get_error ()));
+       }
     }
 #endif
 
@@ -6223,16 +6207,11 @@ s3_s_score_lcomm (int bytes_p)
   *p = c;
 
   if (
-#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
-     || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
-#ifdef BFD_ASSEMBLER
-       (OUTPUT_FLAVOR != bfd_target_aout_flavour
-        || (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0)) &&
-#else
-       (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0) &&
-#endif
+#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
+      (OUTPUT_FLAVOR != bfd_target_aout_flavour
+       || (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0)) &&
 #endif
-       (S_GET_SEGMENT (symbolP) == bss_seg || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
+      (S_GET_SEGMENT (symbolP) == bss_seg || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
     {
       char *pfrag;
 
@@ -6275,12 +6254,12 @@ s3_s_score_lcomm (int bytes_p)
 }
 
 static void
-s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
+s3_insert_reg (const struct s3_reg_entry *r, htab_t 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++)
@@ -6289,8 +6268,8 @@ s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
     }
   buf2[i] = '\0';
 
-  hash_insert (htab, buf, (void *) r);
-  hash_insert (htab, buf2, (void *) r);
+  str_hash_insert (htab, buf, r, 0);
+  str_hash_insert (htab, buf2, r, 0);
 }
 
 static void
@@ -6298,14 +6277,9 @@ s3_build_reg_hsh (struct s3_reg_map *map)
 {
   const struct s3_reg_entry *r;
 
-  if ((map->htab = hash_new ()) == NULL)
-    {
-      as_fatal (_("virtual memory exhausted"));
-    }
+  map->htab = str_htab_create ();
   for (r = map->names; r->name != NULL; r++)
-    {
-      s3_insert_reg (r, map->htab);
-    }
+    s3_insert_reg (r, map->htab);
 }
 
 /* Iterate over the base tables to create the instruction patterns.  */
@@ -6319,20 +6293,22 @@ s3_build_score_ops_hsh (void)
   for (i = 0; i < sizeof (s3_score_insns) / sizeof (struct s3_asm_opcode); i++)
     {
       const struct s3_asm_opcode *insn = s3_score_insns + i;
-      unsigned len = strlen (insn->template);
-      struct s3_asm_opcode *new;
-      char *template;
-      new = obstack_alloc (&insn_obstack, sizeof (struct s3_asm_opcode));
-      template = obstack_alloc (&insn_obstack, len + 1);
+      size_t len = strlen (insn->template_name);
+      struct s3_asm_opcode *new_opcode;
+      char *template_name;
+      new_opcode = (struct s3_asm_opcode *)
+       obstack_alloc (&insn_obstack, sizeof (struct s3_asm_opcode));
+      template_name = (char *) obstack_alloc (& insn_obstack, len + 1);
 
-      strcpy (template, insn->template);
-      new->template = template;
-      new->parms = insn->parms;
-      new->value = insn->value;
-      new->relax_value = insn->relax_value;
-      new->type = insn->type;
-      new->bitmask = insn->bitmask;
-      hash_insert (s3_score_ops_hsh, new->template, (void *) new);
+      strcpy (template_name, insn->template_name);
+      new_opcode->template_name = template_name;
+      new_opcode->parms = insn->parms;
+      new_opcode->value = insn->value;
+      new_opcode->relax_value = insn->relax_value;
+      new_opcode->type = insn->type;
+      new_opcode->bitmask = insn->bitmask;
+      str_hash_insert (s3_score_ops_hsh, new_opcode->template_name,
+                      new_opcode, 0);
     }
 }
 
@@ -6346,15 +6322,19 @@ s3_build_dependency_insn_hsh (void)
   for (i = 0; i < sizeof (s3_insn_to_dependency_table) / sizeof (s3_insn_to_dependency_table[0]); i++)
     {
       const struct s3_insn_to_dependency *tmp = s3_insn_to_dependency_table + i;
-      unsigned len = strlen (tmp->insn_name);
-      struct s3_insn_to_dependency *new;
+      size_t len = strlen (tmp->insn_name);
+      struct s3_insn_to_dependency *new_i2n;
+      char *buf;
 
-      new = obstack_alloc (&dependency_obstack, sizeof (struct s3_insn_to_dependency));
-      new->insn_name = obstack_alloc (&dependency_obstack, len + 1);
+      new_i2n = (struct s3_insn_to_dependency *)
+       obstack_alloc (&dependency_obstack,
+                      sizeof (struct s3_insn_to_dependency));
+      buf = (char *) obstack_alloc (&dependency_obstack, len + 1);
 
-      strcpy (new->insn_name, tmp->insn_name);
-      new->type = tmp->type;
-      hash_insert (s3_dependency_insn_hsh, new->insn_name, (void *) new);
+      strcpy (buf, tmp->insn_name);
+      new_i2n->insn_name = buf;
+      new_i2n->type = tmp->type;
+      str_hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name, new_i2n, 0);
     }
 }
 
@@ -6453,7 +6433,7 @@ s_score_cprestore (int ignore ATTRIBUTE_UNUSED)
 {
   if (score3)
     return s3_s_score_cprestore (ignore);
-  else 
+  else
     return s7_s_score_cprestore (ignore);
 }
 
@@ -6462,7 +6442,7 @@ s_score_gpword (int ignore ATTRIBUTE_UNUSED)
 {
   if (score3)
     return s3_s_score_gpword (ignore);
-  else 
+  else
     return s7_s_score_gpword (ignore);
 }
 
@@ -6471,7 +6451,7 @@ s_score_cpadd (int ignore ATTRIBUTE_UNUSED)
 {
   if (score3)
     return s3_s_score_cpadd (ignore);
-  else 
+  else
     return s7_s_score_cpadd (ignore);
 }
 
@@ -6480,7 +6460,7 @@ s_score_lcomm (int bytes_p)
 {
   if (score3)
     return s3_s_score_lcomm (bytes_p);
-  else 
+  else
     return s7_s_score_lcomm (bytes_p);
 }
 
@@ -6503,11 +6483,11 @@ s3_assemble (char *str)
 }
 
 static void
-s3_operand (expressionS * expr)
+s3_operand (expressionS * exp)
 {
   if (s3_in_my_get_expression)
     {
-      expr->X_op = O_illegal;
+      exp->X_op = O_illegal;
       if (s3_inst.error == NULL)
         {
           s3_inst.error = _("bad expression");
@@ -6522,13 +6502,11 @@ s3_begin (void)
   segT seg;
   subsegT subseg;
 
-  if ((s3_score_ops_hsh = hash_new ()) == NULL)
-    as_fatal (_("virtual memory exhausted"));
+  s3_score_ops_hsh = str_htab_create ();
 
   s3_build_score_ops_hsh ();
 
-  if ((s3_dependency_insn_hsh = hash_new ()) == NULL)
-    as_fatal (_("virtual memory exhausted"));
+  s3_dependency_insn_hsh = str_htab_create ();
 
   s3_build_dependency_insn_hsh ();
 
@@ -6542,8 +6520,8 @@ s3_begin (void)
   seg = now_seg;
   subseg = now_subseg;
   s3_pdr_seg = subseg_new (".pdr", (subsegT) 0);
-  (void)bfd_set_section_flags (stdoutput, s3_pdr_seg, SEC_READONLY | SEC_RELOC | SEC_DEBUGGING);
-  (void)bfd_set_section_alignment (stdoutput, s3_pdr_seg, 2);
+  bfd_set_section_flags (s3_pdr_seg, SEC_READONLY | SEC_RELOC | SEC_DEBUGGING);
+  bfd_set_section_alignment (s3_pdr_seg, 2);
   subseg_set (seg, subseg);
 
   if (s3_USE_GLOBAL_POINTER_OPT)
@@ -6568,21 +6546,21 @@ s3_normal_chars_to_number (char *buf, int n)
   if (target_big_endian)
     {
       while (n--)
-        {       
+        {
           result <<= 8;
-          result |= (*where++ & 255); 
-        }       
+          result |= (*where++ & 255);
+        }
     }
   else
     {
       while (n--)
-        {       
+        {
           result <<= 8;
-          result |= (where[n] & 255); 
-        }       
+          result |= (where[n] & 255);
+        }
     }
 
-  return result; 
+  return result;
 }
 
 static void
@@ -6637,7 +6615,7 @@ s3_chars_to_number_littleendian (const void *p, int n)
 static void
 s3_md_number_to_chars (char *buf, valueT val, int n)
 {
-  if (!target_big_endian && n >= 4) 
+  if (!target_big_endian && n >= 4)
     s3_number_to_chars_littleendian (buf, val, n);
   else
     md_number_to_chars (buf, val, n);
@@ -6656,11 +6634,11 @@ 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;
-  LITTLENUM_TYPE words[s3_MAX_LITTLENUMS];
+  LITTLENUM_TYPE words[MAX_LITTLENUMS];
   char *t;
   int i;
 
@@ -6737,7 +6715,7 @@ s3_force_relocation (struct fix *fixp)
       || fixp->fx_r_type == BFD_RELOC_SCORE_JMP
       || fixp->fx_r_type == BFD_RELOC_SCORE_BRANCH
       || fixp->fx_r_type == BFD_RELOC_SCORE16_JMP
-      || fixp->fx_r_type == BFD_RELOC_SCORE16_BRANCH  
+      || fixp->fx_r_type == BFD_RELOC_SCORE16_BRANCH
       || fixp->fx_r_type == BFD_RELOC_SCORE_BCMP)
     {
       retval = 1;
@@ -6753,7 +6731,7 @@ s3_fix_adjustable (fixS * fixP)
       return 1;
     }
   else if (OUTPUT_FLAVOR == bfd_target_elf_flavour
-      && (S_IS_EXTERNAL (fixP->fx_addsy) || S_IS_WEAK (fixP->fx_addsy)))
+          && (S_IS_EXTERNAL (fixP->fx_addsy) || S_IS_WEAK (fixP->fx_addsy)))
     {
       return 0;
     }
@@ -6805,7 +6783,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);
@@ -6851,10 +6829,7 @@ s3_relax_branch_inst16 (fragS * fragp)
   if (s == NULL)
     frag_addr = 0;
   else
-    {
-      if (s->bsym != 0)
-        symbol_address = (addressT) s->sy_frag->fr_address;
-    }
+    symbol_address = (addressT) symbol_get_frag (s)->fr_address;
 
   inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN16_SIZE);
   offset = (inst_value & 0x1ff) << 1;
@@ -6863,10 +6838,9 @@ s3_relax_branch_inst16 (fragS * fragp)
 
   value = offset + symbol_address - frag_addr;
 
-  if (relaxable_p 
+  if (relaxable_p
       && (!((value & 0xfffffe00) == 0 || (value & 0xfffffe00) == 0xfffffe00))
       && fragp->fr_fix == 2
-      && (s->bsym != NULL)
       && (S_IS_DEFINED (s)
           && !S_IS_COMMON (s)
           && !S_IS_EXTERNAL (s)))
@@ -6898,46 +6872,41 @@ s3_relax_cmpbranch_inst32 (fragS * fragp)
   if (s == NULL)
     frag_addr = 0;
   else
-    {
-      if (s->bsym != 0)
-        symbol_address = (addressT) s->sy_frag->fr_address;
-    }
+    symbol_address = (addressT) symbol_get_frag (s)->fr_address;
 
   inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN_SIZE);
   offset = (inst_value & 0x1)
-           | (((inst_value >> 7) & 0x7) << 1)
-           | (((inst_value >> 21) & 0x1f) << 4);
+    | (((inst_value >> 7) & 0x7) << 1)
+    | (((inst_value >> 21) & 0x1f) << 4);
   offset <<= 1;
   if ((offset & 0x200) == 0x200)
     offset |= 0xfffffe00;
 
   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 
-       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 
+     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
   */
   if (fragp->fr_fix == 6)
-    { 
+    {
       /* Have already relaxed!  Just return 0 to terminate the loop.  */
       return 0;
     }
-  /* need to translate when extern or not defind or common sysbol */
-  else if ((relaxable_p 
-      && (!((value & 0xfffffe00) == 0 || (value & 0xfffffe00) == 0xfffffe00))
-      && fragp->fr_fix == 4
-      && (s->bsym != NULL))
-      || !S_IS_DEFINED (s)
-       ||S_IS_COMMON (s)
-        ||S_IS_EXTERNAL (s))
+  /* 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)
+          || !S_IS_DEFINED (s)
+          ||S_IS_COMMON (s)
+          ||S_IS_EXTERNAL (s))
     {
       fragp->fr_opcode = fragp->fr_literal + s3_RELAX_RELOC1 (fragp->fr_subtype);
       fragp->fr_fix = 6;
       return 2;
     }
-  
   else
-    { 
+    {
       /* Never relax.  Modify fr_opcode to NULL to verify it's value in
          md_apply_fix.  */
       fragp->fr_opcode = NULL;
@@ -6965,7 +6934,7 @@ s3_relax_other_inst32 (fragS * fragp)
 static int
 s3_relax_gp_and_pic_inst32 (void)
 {
-  /* md_estimate_size_before_relax has already relaxed s3_GP and s3_PIC 
+  /* md_estimate_size_before_relax has already relaxed s3_GP and s3_PIC
      instructions.  We don't change relax size here.  */
   return 0;
 }
@@ -6980,11 +6949,11 @@ s3_relax_frag (asection * sec ATTRIBUTE_UNUSED, fragS * fragp, long stretch ATTR
   if ((fragp->fr_address) % 2 != 0)
     {
       if ((fragp->fr_address + fragp->insn_addr) % 2 != 0)
-      {
+       {
           fragp->insn_addr = 1;
           grows += 1;
           adjust_align_p = 1;
-      }
+       }
     }
 
   switch (s3_RELAX_TYPE (fragp->fr_subtype))
@@ -7023,28 +6992,28 @@ s3_relax_frag (asection * sec ATTRIBUTE_UNUSED, fragS * fragp, long stretch ATTR
 static void
 s3_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, fragS * fragp)
 {
-  int old;
-  int new;
+  unsigned int r_old;
+  unsigned int r_new;
   char backup[20];
   fixS *fixp;
 
-  old = s3_RELAX_OLD (fragp->fr_subtype);
-  new = s3_RELAX_NEW (fragp->fr_subtype);
+  r_old = s3_RELAX_OLD (fragp->fr_subtype);
+  r_new = s3_RELAX_NEW (fragp->fr_subtype);
 
   /* fragp->fr_opcode indicates whether this frag should be relaxed.  */
   if (fragp->fr_opcode == NULL)
     {
-      memcpy (backup, fragp->fr_literal, old);
-      fragp->fr_fix = old;
+      memcpy (backup, fragp->fr_literal, r_old);
+      fragp->fr_fix = r_old;
     }
   else
     {
-      memcpy (backup, fragp->fr_literal + old, new);
-      fragp->fr_fix = new;
+      memcpy (backup, fragp->fr_literal + r_old, r_new);
+      fragp->fr_fix = r_new;
     }
 
   fixp = fragp->tc_frag_data.fixp;
-  while (fixp && fixp->fx_frag == fragp && fixp->fx_where < old)
+  while (fixp && fixp->fx_frag == fragp && fixp->fx_where < r_old)
     {
       if (fragp->fr_opcode)
        fixp->fx_done = 1;
@@ -7053,7 +7022,7 @@ s3_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, fragS *
   while (fixp && fixp->fx_frag == fragp)
     {
       if (fragp->fr_opcode)
-       fixp->fx_where -= old + fragp->insn_addr;
+       fixp->fx_where -= r_old + fragp->insn_addr;
       else
        fixp->fx_done = 1;
       fixp = fixp->fx_next;
@@ -7089,17 +7058,17 @@ s3_pcrel_from (fixS * fixP)
 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));
+  int align = bfd_section_alignment (segment);
+  return ((size + (1 << align) - 1) & -(1 << align));
 }
 
 static void
 s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
 {
-  offsetT value = *valP;
-  offsetT newval;
-  offsetT content;
-  unsigned short HI, LO;
+  valueT value = *valP;
+  valueT newval;
+  valueT content;
+  valueT HI, LO;
 
   char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
 
@@ -7130,7 +7099,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
       if (fixP->fx_done)        /* For la rd, imm32.  */
         {
           newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
-          HI = (value) >> 16;   /* mul to 2, then take the hi 16 bit.  */
+          HI = value >> 16;   /* mul to 2, then take the hi 16 bit.  */
           newval |= (HI & 0x3fff) << 1;
           newval |= ((HI >> 14) & 0x3) << 16;
           s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
@@ -7140,7 +7109,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
       if (fixP->fx_done)        /* For la rd, imm32.  */
         {
           newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
-          LO = (value) & 0xffff;
+          LO = value & 0xffff;
           newval |= (LO & 0x3fff) << 1; /* 16 bit: imm -> 14 bit in lo, 2 bit in hi.  */
           newval |= ((LO >> 14) & 0x3) << 16;
           s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
@@ -7161,9 +7130,9 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
         value = fixP->fx_offset;
         value >>= 2;
         content = (content & ~0x7f7fff7f80LL)
-                  | (((value & 0xff) >> 0) << 7)
-                  | (((value & 0x7fff00) >> 8) << 16)
-                  | (((value & 0x3f800000) >> 23) << 32); 
+         | (((value & 0xff) >> 0) << 7)
+         | (((value & 0x7fff00) >> 8) << 16)
+         | (((value & 0x3f800000) >> 23) << 32);
         s3_md_number_to_chars (buf, content, s3_INSN48_SIZE);
         break;
       }
@@ -7173,9 +7142,9 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
         content = s3_md_chars_to_number (buf, s3_INSN48_SIZE);
         value = fixP->fx_offset;
         content = (content & ~0x7f7fff7fe0LL)
-                 | ((value & 0x3ff) << 5)
-                 | (((value >> 10) & 0x7fff) << 16)
-                 | (((value >> 25) & 0x7f) << 32);
+         | ((value & 0x3ff) << 5)
+         | (((value >> 10) & 0x7fff) << 16)
+         | (((value >> 25) & 0x7f) << 32);
         s3_md_number_to_chars (buf, content, s3_INSN48_SIZE);
         break;
       }
@@ -7194,7 +7163,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);
@@ -7209,7 +7178,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);
@@ -7225,7 +7194,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
       content = (content & 0xfc01) | (value & 0xffe);
       s3_md_number_to_chars (buf, content, s3_INSN16_SIZE);
       break;
-   case BFD_RELOC_SCORE16_BRANCH:
+    case BFD_RELOC_SCORE16_BRANCH:
       content = s3_md_chars_to_number (buf, s3_INSN_SIZE);
       /* Don't check c-bit.  */
       if (fixP->fx_frag->fr_opcode != 0)
@@ -7238,7 +7207,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);
@@ -7250,7 +7219,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;
@@ -7260,7 +7229,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;
             }
 
@@ -7270,7 +7239,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           break;
         }
 
-    break;
+      break;
 
     case BFD_RELOC_SCORE_BCMP:
       if (fixP->fx_frag->fr_opcode != 0)
@@ -7283,14 +7252,14 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
           else
             fixP->fx_done = 1;
 
-          /* NOTE!!!  
+          /* NOTE!!!
              bcmp -> cmp! and branch, so value -= 2.  */
           value -= 2;
 
           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;
             }
 
@@ -7315,16 +7284,16 @@ 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;
             }
 
           value >>= 1;
           content &= ~0x03e00381;
           content = content
-                    | (value & 0x1)
-                    | (((value & 0xe) >> 1) << 7)
-                    | (((value & 0x1f0) >> 4) << 21);
+           | (value & 0x1)
+           | (((value & 0xe) >> 1) << 7)
+           | (((value & 0x1f0) >> 4) << 21);
 
           s3_md_number_to_chars (buf, content, s3_INSN_SIZE);
           break;
@@ -7398,15 +7367,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;
-  fragS *f;
-  symbolS *s;
-  expressionS e;
+  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;
@@ -7434,16 +7400,12 @@ 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));
 
-      f = fixp->fx_frag;
-      s = f->fr_symbol;
-      e = s->sy_value;
-
       retval[1]->addend = 0;
       retval[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_LO16);
       gas_assert (retval[1]->howto != NULL);
@@ -7460,6 +7422,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:
@@ -7515,12 +7478,12 @@ md_assemble (char *str)
 /* We handle all bad expressions here, so that we can report the faulty
    instruction in the error message.  */
 void
-md_operand (expressionS * expr)
+md_operand (expressionS * exp)
 {
   if (score3)
-    s3_operand (expr);
+    s3_operand (exp);
   else
-    s7_operand (expr);
+    s7_operand (exp);
 }
 
 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
@@ -7549,7 +7512,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)
@@ -7625,7 +7588,7 @@ score_relax_frag (asection * sec ATTRIBUTE_UNUSED, fragS * fragp, long stretch A
 {
   if (score3)
     return s3_relax_frag (sec, fragp, stretch);
-  else 
+  else
     return s7_relax_frag (sec, fragp, stretch);
 }
 
@@ -7723,7 +7686,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)
     {
@@ -7814,29 +7777,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"));
 }