use XNEW and related macros more
[external/binutils.git] / gas / config / tc-moxie.c
index 430a144..9201cb5 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-moxie.c -- Assemble code for moxie
-   Copyright (C) 2009-2014 Free Software Foundation, Inc.
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -46,7 +46,6 @@ static valueT md_chars_to_number (char * buf, int n);
 
 /* Byte order.  */
 extern int target_big_endian;
-const char *moxie_target_format = DEFAULT_TARGET_FORMAT;
 
 void
 md_operand (expressionS *op __attribute__((unused)))
@@ -75,6 +74,8 @@ md_begin (void)
   for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
     hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
 
+  target_big_endian = TARGET_BYTES_BIG_ENDIAN;
+
   bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
 }
 
@@ -403,7 +404,7 @@ md_assemble (char *str)
        iword += (a << 4);
       }
       break;
-    case MOXIE_F1_ABi4:
+    case MOXIE_F1_ABi2:
       iword = opcode->opcode << 8;
       while (ISSPACE (*op_end))
        op_end++;
@@ -425,13 +426,13 @@ md_assemble (char *str)
        op_end++;
 
        op_end = parse_exp_save_ilp (op_end, &arg);
-       offset = frag_more (4);
+       offset = frag_more (2);
        fix_new_exp (frag_now,
                     (offset - frag_now->fr_literal),
-                    4,
+                    2,
                     &arg,
                     0,
-                    BFD_RELOC_32);
+                    BFD_RELOC_16);
 
        if (*op_end != '(')
          {
@@ -457,7 +458,7 @@ md_assemble (char *str)
        iword += (a << 4) + b;
       }
       break;
-    case MOXIE_F1_AiB4:
+    case MOXIE_F1_AiB2:
       iword = opcode->opcode << 8;
       while (ISSPACE (*op_end))
        op_end++;
@@ -467,13 +468,13 @@ md_assemble (char *str)
        int a, b;
 
        op_end = parse_exp_save_ilp (op_end, &arg);
-       offset = frag_more (4);
+       offset = frag_more (2);
        fix_new_exp (frag_now,
                     (offset - frag_now->fr_literal),
-                    4,
+                    2,
                     &arg,
                     0,
-                    BFD_RELOC_32);
+                    BFD_RELOC_16);
 
        if (*op_end != '(')
          {
@@ -555,7 +556,7 @@ md_assemble (char *str)
    of LITTLENUMS emitted is stored in *SIZEP .  An error message is
    returned, or NULL on OK.  */
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   int prec;
@@ -611,19 +612,17 @@ size_t md_longopts_size = sizeof (md_longopts);
 const char *md_shortopts = "";
 
 int
-md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
+md_parse_option (int c ATTRIBUTE_UNUSED, const char *arg ATTRIBUTE_UNUSED)
 {
   switch (c)
     {
-    case OPTION_EB: 
-      target_big_endian = 1; 
-      moxie_target_format = "elf32-bigmoxie";
+    case OPTION_EB:
+      target_big_endian = 1;
       break;
-    case OPTION_EL: 
+    case OPTION_EL:
       target_big_endian = 0;
-      moxie_target_format = "elf32-littlemoxie";
       break;
-    default:        
+    default:
       return 0;
     }
 
@@ -641,7 +640,7 @@ md_show_usage (FILE *stream ATTRIBUTE_UNUSED)
 /* Apply a fixup to the object file.  */
 
 void
-md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED, 
+md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
              valueT * valP ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED)
 {
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
@@ -772,9 +771,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
       return 0;
     }
 
-  relP = xmalloc (sizeof (arelent));
-  gas_assert (relP != 0);
-  relP->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+  relP = XNEW (arelent);
+  relP->sym_ptr_ptr = XNEW (asymbol *);
   *relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   relP->address = fixP->fx_frag->fr_address + fixP->fx_where;