aarch64: make the type of reg_entry::type aarch64_reg_type
[deliverable/binutils-gdb.git] / gas / config / obj-elf.c
index bacaca3f30a70c631d6fccc5d78df962928c8a8d..8af563fbd24e6d1c6c1b99175d77248eace9745a 100644 (file)
@@ -568,7 +568,7 @@ obj_elf_change_section (const char *name,
   if (push)
     {
       struct section_stack *elt;
-      elt = (struct section_stack *) xmalloc (sizeof (struct section_stack));
+      elt = XNEW (struct section_stack);
       elt->next = section_stack;
       elt->seg = now_seg;
       elt->prev_seg = previous_section;
@@ -815,7 +815,8 @@ obj_elf_parse_section_letters (char *str, size_t len, bfd_boolean *is_clone)
            }
        default:
          {
-           char *bad_msg = _("unrecognized .section attribute: want a,e,w,x,M,S,G,T or number");
+           const char *bad_msg = _("unrecognized .section attribute:"
+                                   " want a,e,w,x,M,S,G,T or number");
 #ifdef md_elf_section_letter
            bfd_vma md_attr = md_elf_section_letter (*str, &bad_msg);
            if (md_attr != (bfd_vma) -1)
@@ -918,7 +919,7 @@ obj_elf_section_word (char *str, size_t len, int *type)
 }
 
 /* Get name of section.  */
-char *
+const char *
 obj_elf_section_name (void)
 {
   char *name;
@@ -948,9 +949,7 @@ obj_elf_section_name (void)
          return NULL;
        }
 
-      name = (char *) xmalloc (end - input_line_pointer + 1);
-      memcpy (name, input_line_pointer, end - input_line_pointer);
-      name[end - input_line_pointer] = '\0';
+      name = xmemdup0 (input_line_pointer, end - input_line_pointer);
 
       while (flag_sectname_subst)
         {
@@ -960,7 +959,7 @@ obj_elf_section_name (void)
              int oldlen = strlen (name);
              int substlen = strlen (now_seg->name);
              int newlen = oldlen - 2 + substlen;
-             char *newname = (char *) xmalloc (newlen + 1);
+             char *newname = XNEWVEC (char, newlen + 1);
              int headlen = subst - name;
              memcpy (newname, name, headlen);
              strcpy (newname + headlen, now_seg->name);
@@ -984,7 +983,8 @@ obj_elf_section_name (void)
 void
 obj_elf_section (int push)
 {
-  char *name, *group_name, *beg;
+  const char *name, *group_name;
+  char *beg;
   int type, dummy;
   bfd_vma attr;
   int entsize;
@@ -1607,9 +1607,7 @@ obj_elf_vendor_attribute (int vendor)
       if (i == 0)
        goto bad;
 
-      name = xmalloc (i + 1);
-      memcpy (name, s, i);
-      name[i] = '\0';
+      name = xstrndup (s, i);
 
 #ifndef CONVERT_SYMBOLIC_ATTRIBUTE
 #define CONVERT_SYMBOLIC_ATTRIBUTE(a) -1
@@ -1730,7 +1728,7 @@ elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
   if (srcelf->size)
     {
       if (destelf->size == NULL)
-       destelf->size = (expressionS *) xmalloc (sizeof (expressionS));
+       destelf->size = XNEW (expressionS);
       *destelf->size = *srcelf->size;
     }
   else
@@ -1847,8 +1845,7 @@ obj_elf_size (int ignore ATTRIBUTE_UNUSED)
     }
   else
     {
-      symbol_get_obj (sym)->size =
-          (expressionS *) xmalloc (sizeof (expressionS));
+      symbol_get_obj (sym)->size = XNEW (expressionS);
       *symbol_get_obj (sym)->size = exp;
     }
   demand_empty_rest_of_line ();
@@ -2061,9 +2058,7 @@ obj_elf_init_stab_section (segT seg)
   /* Zero it out.  */
   memset (p, 0, 12);
   file = as_where (NULL);
-  stabstr_name = (char *) xmalloc (strlen (segment_name (seg)) + 4);
-  strcpy (stabstr_name, segment_name (seg));
-  strcat (stabstr_name, "str");
+  stabstr_name = concat (segment_name (seg), "str", (char *) NULL);
   stroff = get_stab_string_offset (file, stabstr_name);
   know (stroff == 1 || (stroff == 0 && file[0] == '\0'));
   md_number_to_chars (p, stroff, 4);
@@ -2165,7 +2160,7 @@ elf_frob_symbol (symbolS *symp, int *puntp)
        S_SET_SIZE (symp, size->X_add_number);
       else
        {
-         if (flag_size_check == size_check_error)
+         if (!flag_allow_nonconst_size)
            as_bad (_(".size expression for %s "
                      "does not evaluate to a constant"), S_GET_NAME (symp));
          else
@@ -2329,17 +2324,15 @@ build_group_lists (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
   if ((i & 127) == 0)
     {
       unsigned int newsize = i + 128;
-      list->head = (asection **) xrealloc (list->head,
-                                           newsize * sizeof (*list->head));
-      list->elt_count = (unsigned int *)
-          xrealloc (list->elt_count, newsize * sizeof (*list->elt_count));
+      list->head = XRESIZEVEC (asection *, list->head, newsize);
+      list->elt_count = XRESIZEVEC (unsigned int, list->elt_count, newsize);
     }
   list->head[i] = sec;
   list->elt_count[i] = 1;
   list->num_group += 1;
 
   /* Add index to hash.  */
-  idx_ptr = (unsigned int *) xmalloc (sizeof (unsigned int));
+  idx_ptr = XNEW (unsigned int);
   *idx_ptr = i;
   hash_insert (list->indexes, group_name, idx_ptr);
 }
This page took 0.025019 seconds and 4 git commands to generate.