]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-xstormy16.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / tc-xstormy16.c
index 4cdb0ee8e098d6781a9bcb3e6a6d7551b37fa8e4..0deec54ca4c3e4894694b07e40c21dabdd72fa6f 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-xstormy16.c -- Assembler for the Sanyo XSTORMY16.
-   Copyright (C) 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 2000-2023 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -66,7 +66,7 @@ size_t md_longopts_size = sizeof (md_longopts);
 
 int
 md_parse_option (int    c ATTRIBUTE_UNUSED,
-                char * arg ATTRIBUTE_UNUSED)
+                const char * arg ATTRIBUTE_UNUSED)
 {
   return 0;
 }
@@ -101,7 +101,7 @@ md_begin (void)
   cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);
 }
 
-static bfd_boolean skipping_fptr = FALSE;
+static bool skipping_fptr = false;
 
 void
 md_assemble (char * str)
@@ -111,7 +111,7 @@ md_assemble (char * str)
 
   /* Make sure that if we had an erroneous input line which triggered
      the skipping_fptr boolean that it does not affect following lines.  */
-  skipping_fptr = FALSE;
+  skipping_fptr = false;
 
   /* Initialize GAS's cgen interface for a new instruction.  */
   gas_cgen_init_parse ();
@@ -136,7 +136,7 @@ md_operand (expressionS * e)
   if (*input_line_pointer != '@')
     return;
 
-  if (strncmp (input_line_pointer + 1, "fptr", 4) == 0)
+  if (startswith (input_line_pointer + 1, "fptr"))
     {
       input_line_pointer += 5;
       SKIP_WHITESPACE ();
@@ -174,9 +174,9 @@ md_operand (expressionS * e)
          example) might be local symbols and we want the expression
          to be evaluated now.  This kind of thing can happen when
          gcc is generating computed gotos.  */
-       skipping_fptr = TRUE;
+       skipping_fptr = true;
       else if (skipping_fptr)
-       skipping_fptr = FALSE;
+       skipping_fptr = false;
       else
         e->X_op = O_fptr_symbol;
     }
@@ -204,9 +204,9 @@ xstormy16_cons_fix_new (fragS *f,
          /* This can happen when gcc is generating debug output.
             For example it can create a stab with the address of
             a function:
-            
+
                .stabs  "foo:F(0,21)",36,0,0,@fptr(foo)
+
             Since this does not involve switching code pages, we
             just allow the reloc to be generated without any
             @fptr behaviour.  */
@@ -277,9 +277,9 @@ xstormy16_cgen_record_fixup_exp (fragS *              frag,
 valueT
 md_section_align (segT segment, valueT size)
 {
-  int align = bfd_get_section_alignment (stdoutput, segment);
+  int align = bfd_section_alignment (segment);
 
-  return ((size + (1 << align) - 1) & (-1 << align));
+  return ((size + (1 << align) - 1) & -(1 << align));
 }
 
 symbolS *
@@ -337,7 +337,7 @@ md_pcrel_from_section (fixS * fixP, segT sec)
       || xstormy16_force_relocation (fixP))
     /* The symbol is undefined,
        or it is defined but not in this section,
-       or the relocation will be relative to this symbol not the section symbol.        
+       or the relocation will be relative to this symbol not the section symbol.
        Let the linker figure it out.  */
     return 0;
 
@@ -382,6 +382,7 @@ md_cgen_lookup_reloc (const CGEN_INSN *    insn ATTRIBUTE_UNUSED,
 
     case XSTORMY16_OPERAND_REL8_4:
       fixP->fx_addnumber -= 2;
+      /* Fall through.  */
     case XSTORMY16_OPERAND_REL8_2:
       fixP->fx_addnumber -= 2;
       fixP->fx_pcrel = 1;
@@ -389,7 +390,7 @@ md_cgen_lookup_reloc (const CGEN_INSN *    insn ATTRIBUTE_UNUSED,
 
     case XSTORMY16_OPERAND_REL12:
       fixP->fx_where += 2;
-      /* Fall through...  */
+      /* Fall through.  */
     case XSTORMY16_OPERAND_REL12A:
       fixP->fx_addnumber -= 2;
       fixP->fx_pcrel = 1;
@@ -416,18 +417,18 @@ xstormy16_force_relocation (fixS * fix)
 /* Return true if a relocation against a symbol may be replaced with
    a relocation against section+offset.  */
 
-bfd_boolean
+bool
 xstormy16_fix_adjustable (fixS * fixP)
 {
   /* We need the symbol name for the VTABLE entries.  */
   if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
       || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
-    return FALSE;
+    return false;
 
   if (fixP->fx_r_type == BFD_RELOC_XSTORMY16_FPTR16)
-    return FALSE;
+    return false;
 
-  return TRUE;
+  return true;
 }
 
 /* This is a copy of gas_cgen_md_apply_fix, with some enhancements to
@@ -478,7 +479,7 @@ xstormy16_md_apply_fix (fixS *   fixP,
 
   /* We don't actually support subtracting a symbol.  */
   if (fixP->fx_subsy != (symbolS *) NULL)
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
     {
@@ -486,13 +487,14 @@ xstormy16_md_apply_fix (fixS *   fixP,
       const CGEN_OPERAND *operand = cgen_operand_lookup_by_num (cd, opindex);
       const char *errmsg;
       bfd_reloc_code_real_type reloc_type;
-      CGEN_FIELDS *fields = alloca (CGEN_CPU_SIZEOF_FIELDS (cd));
       const CGEN_INSN *insn = fixP->fx_cgen.insn;
 
       /* If the reloc has been fully resolved finish the operand here.  */
       /* FIXME: This duplicates the capabilities of code in BFD.  */
       if (fixP->fx_done)
        {
+         CGEN_FIELDS *fields = xmalloc (CGEN_CPU_SIZEOF_FIELDS (cd));
+
          CGEN_CPU_SET_FIELDS_BITSIZE (cd) (fields, CGEN_INSN_BITSIZE (insn));
          CGEN_CPU_SET_VMA_OPERAND (cd) (cd, opindex, fields, (bfd_vma) value);
 
@@ -500,13 +502,15 @@ xstormy16_md_apply_fix (fixS *   fixP,
          {
            CGEN_INSN_INT insn_value =
              cgen_get_insn_value (cd, (unsigned char *) where,
-                                  CGEN_INSN_BITSIZE (insn));
+                                  CGEN_INSN_BITSIZE (insn),
+                                  gas_cgen_cpu_desc->insn_endian);
 
            /* ??? 0 is passed for `pc'.  */
            errmsg = CGEN_CPU_INSERT_OPERAND (cd) (cd, opindex, fields,
                                                   &insn_value, (bfd_vma) 0);
            cgen_put_insn_value (cd, (unsigned char *) where,
-                                CGEN_INSN_BITSIZE (insn), insn_value);
+                                CGEN_INSN_BITSIZE (insn), insn_value,
+                                gas_cgen_cpu_desc->insn_endian);
          }
 #else
          /* ??? 0 is passed for `pc'.  */
@@ -516,6 +520,8 @@ xstormy16_md_apply_fix (fixS *   fixP,
 #endif
          if (errmsg)
            as_bad_where (fixP->fx_file, fixP->fx_line, "%s", errmsg);
+
+         free (fields);
        }
 
       if (fixP->fx_done)
@@ -593,8 +599,8 @@ md_number_to_chars (char * buf, valueT val, int n)
   number_to_chars_littleendian (buf, val, n);
 }
 
-char *
+const char *
 md_atof (int type, char * litP, int * sizeP)
 {
-  return ieee_md_atof (type, litP, sizeP, FALSE);
+  return ieee_md_atof (type, litP, sizeP, false);
 }