make md_parse_option () take a const char *
[external/binutils.git] / gas / config / tc-dlx.c
index 55643a6..970e297 100644 (file)
@@ -1,5 +1,5 @@
-/* tc-ldx.c -- Assemble for the DLX
-   Copyright 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+/* tc-dlx.c -- Assemble for the DLX
+   Copyright (C) 2002-2016 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -20,8 +20,8 @@
 
 /* Initially created by Kuang Hwa Lin, 3/20/2002.  */
 
-#include "safe-ctype.h"
 #include "as.h"
+#include "safe-ctype.h"
 #include "tc-dlx.h"
 #include "opcode/dlx.h"
 
@@ -84,7 +84,7 @@ const char EXP_CHARS[] = "eE";
 const char FLT_CHARS[] = "rRsSfFdDxXpP";
 
 static void
-insert_sreg (char *regname, int regnum)
+insert_sreg (const char *regname, int regnum)
 {
   /* Must be large enough to hold the names of the special registers.  */
   char buf[80];
@@ -153,7 +153,7 @@ match_sft_register (char *name)
 #define MAX_REG_NO  35
 /* Currently we have 35 software registers defined -
    we borrowed from MIPS.   */
-  static char *soft_reg[] =
+  static const char *soft_reg[] =
     {
       "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
       "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9",
@@ -230,11 +230,10 @@ s_proc (int end_p)
          return;
        }
 
-      name = input_line_pointer;
-      delim1 = get_symbol_end ();
+      delim1 = get_symbol_name (&name);
       name = xstrdup (name);
       *input_line_pointer = delim1;
-      SKIP_WHITESPACE ();
+      SKIP_WHITESPACE_AFTER_NAME ();
 
       if (*input_line_pointer != ',')
        {
@@ -244,7 +243,12 @@ s_proc (int end_p)
          /* Missing entry point, use function's name with the leading
             char prepended.  */
          if (leading_char)
-           asprintf (&label, "%c%s", leading_char, name);
+           {
+             unsigned len = strlen (name) + 1;
+             label = xmalloc (len + 1);
+             label[0] = leading_char;
+             memcpy (label + 1, name, len);
+           }
          else
            label = name;
        }
@@ -252,10 +256,9 @@ s_proc (int end_p)
        {
          ++input_line_pointer;
          SKIP_WHITESPACE ();
-         label = input_line_pointer;
-         delim2 = get_symbol_end ();
+         delim2 = get_symbol_name (&label);
          label = xstrdup (label);
-         *input_line_pointer = delim2;
+         (void) restore_line_pointer (delim2);
        }
 
       current_name = name;
@@ -656,12 +659,14 @@ machine_ip (char *str)
   char *s;
   const char *args;
   struct machine_opcode *insn;
-  char *argsStart;
   unsigned long opcode;
   expressionS the_operand;
   expressionS *operand = &the_operand;
   unsigned int reg, reg_shift = 0;
 
+  memset (&the_insn, '\0', sizeof (the_insn));
+  the_insn.reloc = NO_RELOC;
+
   /* Fixup the opcode string to all lower cases, and also
      allow numerical digits.  */
   s = str;
@@ -686,30 +691,19 @@ machine_ip (char *str)
       return;
     }
 
-  /* Hash the opcode, insn will have the string from opcode table.
-     also initialized the_insn struct.  */
+  /* Hash the opcode, insn will have the string from opcode table.  */
   if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
     {
       /* Handle the ret and return macro here.  */
       if ((strcmp (str, "ret") == 0) || (strcmp (str, "return") == 0))
-       {
-         memset (&the_insn, '\0', sizeof (the_insn));
-         the_insn.reloc = NO_RELOC;
-         the_insn.pcrel = 0;
-         the_insn.opcode =
-           (unsigned long)(JROP | 0x03e00000);    /* 0x03e00000 = r31 << 21 */
-       }
+       the_insn.opcode = JROP | 0x03e00000;    /* 0x03e00000 = r31 << 21 */
       else
        as_bad (_("Unknown opcode `%s'."), str);
 
       return;
     }
 
-  argsStart = s;
   opcode = insn->opcode;
-  memset (&the_insn, '\0', sizeof (the_insn));
-  the_insn.reloc = NO_RELOC;
-  the_insn.pcrel = 0;
 
   /* Set the sip reloc HI16 flag.  */
   if (!set_dlx_skip_hi16_flag (1))
@@ -807,7 +801,7 @@ machine_ip (char *str)
              continue;
            }
 
-         the_insn.reloc        = (the_insn.HI) ? RELOC_DLX_HI16 
+         the_insn.reloc        = (the_insn.HI) ? RELOC_DLX_HI16
            : (the_insn.LO ? RELOC_DLX_LO16 : RELOC_DLX_16);
          the_insn.reloc_offset = 2;
          the_insn.size         = 2;
@@ -908,6 +902,8 @@ md_assemble (char *str)
   know (str);
   machine_ip (str);
   toP = frag_more (4);
+  dwarf2_emit_insn (4);
+
   /* Put out the opcode.  */
   md_number_to_chars (toP, the_insn.opcode, 4);
 
@@ -1080,7 +1076,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;
 }