[AArch64] Fix typo in comments on relocation name
[deliverable/binutils-gdb.git] / gas / config / tc-hppa.c
index 48fdb0f87723e72bb551ff218e4e7442b0dfc258..724b48bfbce0d102f980f4f0a3bf3f809320404f 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-hppa.c -- Assemble for the PA
-   Copyright (C) 1989-2016 Free Software Foundation, Inc.
+   Copyright (C) 1989-2017 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -350,7 +350,7 @@ typedef struct space_dictionary_chain sd_chain_struct;
 struct default_subspace_dict
   {
     /* Name of the subspace.  */
-    char *name;
+    const char *name;
 
     /* FIXME.  Is this still needed?  */
     char defined;
@@ -403,7 +403,7 @@ struct default_subspace_dict
 struct default_space_dict
   {
     /* Name of the space.  */
-    char *name;
+    const char *name;
 
     /* Space number.  It is possible to identify spaces within
        assembly code numerically!  */
@@ -503,27 +503,27 @@ static void pa_align (int);
 static void pa_space (int);
 static void pa_spnum (int);
 static void pa_subspace (int);
-static sd_chain_struct *create_new_space (char *, int, int,
-                                                 int, int, int,
-                                                 asection *, int);
+static sd_chain_struct *create_new_space (const char *, int, int,
+                                         int, int, int,
+                                         asection *, int);
 static ssd_chain_struct *create_new_subspace (sd_chain_struct *,
-                                                     char *, int, int,
-                                                     int, int, int, int,
-                                                     int, int, int, int,
-                                                     int, asection *);
+                                             const char *, int, int,
+                                             int, int, int, int,
+                                             int, int, int, int,
+                                             int, asection *);
 static ssd_chain_struct *update_subspace (sd_chain_struct *,
-                                                 char *, int, int, int,
-                                                 int, int, int, int,
-                                                 int, int, int, int,
-                                                 asection *);
-static sd_chain_struct *is_defined_space (char *);
-static ssd_chain_struct *is_defined_subspace (char *);
+                                         char *, int, int, int,
+                                         int, int, int, int,
+                                         int, int, int, int,
+                                         asection *);
+static sd_chain_struct *is_defined_space (const char *);
+static ssd_chain_struct *is_defined_subspace (const char *);
 static sd_chain_struct *pa_segment_to_space (asection *);
 static ssd_chain_struct *pa_subsegment_to_subspace (asection *,
                                                            subsegT);
 static sd_chain_struct *pa_find_space_by_number (int);
 static unsigned int pa_subspace_start (sd_chain_struct *, int);
-static sd_chain_struct *pa_parse_space_stmt (char *, int);
+static sd_chain_struct *pa_parse_space_stmt (const char *, int);
 #endif
 
 /* File and globally scoped variable declarations.  */
@@ -1319,7 +1319,7 @@ pa_parse_nullif (char **s)
   return nullif;
 }
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   return ieee_md_atof (type, litP, sizeP, TRUE);
@@ -1355,9 +1355,9 @@ tc_gen_reloc (asection *section, fixS *fixp)
   gas_assert (hppa_fixp != 0);
   gas_assert (section != 0);
 
-  reloc = xmalloc (sizeof (arelent));
+  reloc = XNEW (arelent);
 
-  reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
 
   /* Allow fixup_segment to recognize hand-written pc-relative relocations.
@@ -1388,8 +1388,8 @@ tc_gen_reloc (asection *section, fixS *fixp)
   for (n_relocs = 0; codes[n_relocs]; n_relocs++)
     ;
 
-  relocs = xmalloc (sizeof (arelent *) * n_relocs + 1);
-  reloc = xmalloc (sizeof (arelent) * n_relocs);
+  relocs = XNEWVEC (arelent *, n_relocs + 1);
+  reloc = XNEWVEC (arelent, n_relocs);
   for (i = 0; i < n_relocs; i++)
     relocs[i] = &reloc[i];
 
@@ -1440,14 +1440,14 @@ tc_gen_reloc (asection *section, fixS *fixp)
          /* Facilitate hand-crafted unwind info.  */
          if (strcmp (section->name, UNWIND_SECTION_NAME) == 0)
            code = R_PARISC_SEGREL32;
-         /* Fall thru */
+         /* Fallthru */
 
        default:
          reloc->addend = fixp->fx_offset;
          break;
        }
 
-      reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+      reloc->sym_ptr_ptr = XNEW (asymbol *);
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       reloc->howto = bfd_reloc_type_lookup (stdoutput,
                                            (bfd_reloc_code_real_type) code);
@@ -1463,7 +1463,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
     {
       code = *codes[i];
 
-      relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+      relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
       *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       relocs[i]->howto =
        bfd_reloc_type_lookup (stdoutput,
@@ -1484,14 +1484,14 @@ tc_gen_reloc (asection *section, fixS *fixp)
                                     (bfd_reloc_code_real_type) *codes[0]);
          relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
          relocs[0]->addend = 0;
-         relocs[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+         relocs[1]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
          relocs[1]->howto
            = bfd_reloc_type_lookup (stdoutput,
                                     (bfd_reloc_code_real_type) *codes[1]);
          relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
          relocs[1]->addend = 0;
-         relocs[2]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+         relocs[2]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
          relocs[2]->howto
            = bfd_reloc_type_lookup (stdoutput,
@@ -1546,7 +1546,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
        case R_N0SEL:
        case R_N1SEL:
          /* There is no symbol or addend associated with these fixups.  */
-         relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+         relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
          relocs[i]->addend = 0;
          break;
@@ -1555,7 +1555,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
        case R_ENTRY:
        case R_EXIT:
          /* There is no symbol associated with these fixups.  */
-         relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+         relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
          relocs[i]->addend = fixp->fx_offset;
          break;
@@ -3505,8 +3505,9 @@ pa_ip (char *str)
                        /* M bit is explicit in the major opcode.  */
                        INSERT_FIELD_AND_CONTINUE (opcode, a, 2);
                      }
-                   else if (*args == 'e')
+                   else
                      {
+                       gas_assert (*args == 'e');
                        /* Stash the ma/mb flag temporarily in the
                           instruction.  We will use (and remove it)
                           later when handling 'J', 'K', '<' & '>'.  */
@@ -5431,6 +5432,7 @@ pa_ip (char *str)
                {
                case SGL:
                  opcode |= 0x20;
+                 /* Fall through.  */
                case DBL:
                  the_insn.fpof1 = flag;
                  continue;
@@ -5685,7 +5687,7 @@ pa_ip (char *str)
       /* If this instruction is specific to a particular architecture,
         then set a new architecture.  This automatic promotion crud is
         for compatibility with HP's old assemblers only.  */
-      if (match == TRUE
+      if (match
          && bfd_get_mach (stdoutput) < insn->arch
          && !bfd_set_arch_mach (stdoutput, bfd_arch_hppa, insn->arch))
        {
@@ -5974,11 +5976,8 @@ pa_build_unwind_subspace (struct call_info *call_info)
   /* Replace the start symbol with a local symbol that will be reduced
      to a section offset.  This avoids problems with weak functions with
      multiple definitions, etc.  */
-  name = xmalloc (strlen ("L$\001start_")
-                 + strlen (S_GET_NAME (call_info->start_symbol))
-                 + 1);
-  strcpy (name, "L$\001start_");
-  strcat (name, S_GET_NAME (call_info->start_symbol));
+  name = concat ("L$\001start_", S_GET_NAME (call_info->start_symbol),
+                (char *) NULL);
 
   /* If we have a .procend preceded by a .exit, then the symbol will have
      already been defined.  In that case, we don't want another unwind
@@ -6414,6 +6413,7 @@ hppa_elf_mark_end_of_function (void)
   /* ELF does not have EXIT relocations.  All we do is create a
      temporary symbol marking the end of the function.  */
   char *name;
+  symbolS *symbolP;
 
   if (last_call_info == NULL || last_call_info->start_symbol == NULL)
     {
@@ -6422,48 +6422,37 @@ hppa_elf_mark_end_of_function (void)
       return;
     }
 
-  name = xmalloc (strlen ("L$\001end_")
-                 + strlen (S_GET_NAME (last_call_info->start_symbol))
-                 + 1);
-  if (name)
-    {
-      symbolS *symbolP;
-
-      strcpy (name, "L$\001end_");
-      strcat (name, S_GET_NAME (last_call_info->start_symbol));
+  name = concat ("L$\001end_", S_GET_NAME (last_call_info->start_symbol),
+                (char *) NULL);
 
-      /* If we have a .exit followed by a .procend, then the
-        symbol will have already been defined.  */
-      symbolP = symbol_find (name);
-      if (symbolP)
-       {
-         /* The symbol has already been defined!  This can
-            happen if we have a .exit followed by a .procend.
-
-            This is *not* an error.  All we want to do is free
-            the memory we just allocated for the name and continue.  */
-         xfree (name);
-       }
-      else
-       {
-         /* symbol value should be the offset of the
-            last instruction of the function */
-         symbolP = symbol_new (name, now_seg, (valueT) (frag_now_fix () - 4),
-                               frag_now);
-
-         gas_assert (symbolP);
-         S_CLEAR_EXTERNAL (symbolP);
-         symbol_table_insert (symbolP);
-       }
+  /* If we have a .exit followed by a .procend, then the
+     symbol will have already been defined.  */
+  symbolP = symbol_find (name);
+  if (symbolP)
+    {
+      /* The symbol has already been defined!  This can
+        happen if we have a .exit followed by a .procend.
 
-      if (symbolP)
-       last_call_info->end_symbol = symbolP;
-      else
-       as_bad (_("Symbol '%s' could not be created."), name);
+        This is *not* an error.  All we want to do is free
+        the memory we just allocated for the name and continue.  */
+      xfree (name);
+    }
+  else
+    {
+      /* symbol value should be the offset of the
+        last instruction of the function */
+      symbolP = symbol_new (name, now_seg, (valueT) (frag_now_fix () - 4),
+                           frag_now);
 
+      gas_assert (symbolP);
+      S_CLEAR_EXTERNAL (symbolP);
+      symbol_table_insert (symbolP);
     }
+
+  if (symbolP)
+    last_call_info->end_symbol = symbolP;
   else
-    as_bad (_("No memory for symbol name."));
+    as_bad (_("Symbol '%s' could not be created."), name);
 }
 #endif
 
@@ -6925,7 +6914,7 @@ pa_proc (int unused ATTRIBUTE_UNUSED)
   within_procedure = TRUE;
 
   /* Create another call_info structure.  */
-  call_info = xmalloc (sizeof (struct call_info));
+  call_info = XNEW (struct call_info);
 
   if (!call_info)
     as_fatal (_("Cannot allocate unwind descriptor\n"));
@@ -7036,7 +7025,7 @@ pa_procend (int unused ATTRIBUTE_UNUSED)
 
 #ifdef OBJ_ELF
   /* ELF needs to mark the end of each function so that it can compute
-     the size of the function (apparently its needed in the symbol table).  */
+     the size of the function (apparently it's needed in the symbol table).  */
   hppa_elf_mark_end_of_function ();
 #endif
 
@@ -7080,7 +7069,7 @@ pa_check_current_space_and_subspace (void)
    by the parameters to the .SPACE directive.  */
 
 static sd_chain_struct *
-pa_parse_space_stmt (char *space_name, int create_flag)
+pa_parse_space_stmt (const char *space_name, int create_flag)
 {
   char *name, *ptemp, c;
   char loadable, defined, private, sort;
@@ -7300,8 +7289,7 @@ pa_space (int unused ATTRIBUTE_UNUSED)
       print_errors = 1;
       input_line_pointer = save_s;
       c = get_symbol_name (&name);
-      space_name = xmalloc (strlen (name) + 1);
-      strcpy (space_name, name);
+      space_name = xstrdup (name);
       (void) restore_line_pointer (c);
 
       sd_chain = pa_parse_space_stmt (space_name, 1);
@@ -7365,8 +7353,7 @@ pa_subspace (int create_new)
   else
     {
       c = get_symbol_name (&name);
-      ss_name = xmalloc (strlen (name) + 1);
-      strcpy (ss_name, name);
+      ss_name = xstrdup (name);
       (void) restore_line_pointer (c);
 
       /* Load default values.  */
@@ -7592,7 +7579,7 @@ pa_spaces_begin (void)
   i = 0;
   while (pa_def_spaces[i].name)
     {
-      char *name;
+      const char *name;
 
       /* Pick the right name to use for the new section.  */
       name = pa_def_spaces[i].name;
@@ -7608,7 +7595,7 @@ pa_spaces_begin (void)
   i = 0;
   while (pa_def_subspaces[i].name)
     {
-      char *name;
+      const char *name;
       int applicable, subsegment;
       asection *segment = NULL;
       sd_chain_struct *space;
@@ -7709,7 +7696,7 @@ pa_spaces_begin (void)
    by the given parameters.  */
 
 static sd_chain_struct *
-create_new_space (char *name,
+create_new_space (const char *name,
                  int spnum,
                  int loadable ATTRIBUTE_UNUSED,
                  int defined,
@@ -7720,13 +7707,8 @@ create_new_space (char *name,
 {
   sd_chain_struct *chain_entry;
 
-  chain_entry = xmalloc (sizeof (sd_chain_struct));
-  if (!chain_entry)
-    as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
-             name);
-
-  SPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1);
-  strcpy (SPACE_NAME (chain_entry), name);
+  chain_entry = XNEW (sd_chain_struct);
+  SPACE_NAME (chain_entry) = xstrdup (name);
   SPACE_DEFINED (chain_entry) = defined;
   SPACE_USER_DEFINED (chain_entry) = user_defined;
   SPACE_SPNUM (chain_entry) = spnum;
@@ -7792,7 +7774,7 @@ create_new_space (char *name,
 
 static ssd_chain_struct *
 create_new_subspace (sd_chain_struct *space,
-                    char *name,
+                    const char *name,
                     int loadable ATTRIBUTE_UNUSED,
                     int code_only ATTRIBUTE_UNUSED,
                     int comdat,
@@ -7808,12 +7790,8 @@ create_new_subspace (sd_chain_struct *space,
 {
   ssd_chain_struct *chain_entry;
 
-  chain_entry = xmalloc (sizeof (ssd_chain_struct));
-  if (!chain_entry)
-    as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name);
-
-  SUBSPACE_NAME (chain_entry) = xmalloc (strlen (name) + 1);
-  strcpy (SUBSPACE_NAME (chain_entry), name);
+  chain_entry = XNEW (ssd_chain_struct);
+  SUBSPACE_NAME (chain_entry) = xstrdup (name);
 
   /* Initialize subspace_defined.  When we hit a .subspace directive
      we'll set it to 1 which "locks-in" the subspace attributes.  */
@@ -7897,7 +7875,7 @@ update_subspace (sd_chain_struct *space,
    NULL if no such space exists.  */
 
 static sd_chain_struct *
-is_defined_space (char *name)
+is_defined_space (const char *name)
 {
   sd_chain_struct *chain_pointer;
 
@@ -7946,7 +7924,7 @@ pa_segment_to_space (asection *seg)
    own subspace.  */
 
 static ssd_chain_struct *
-is_defined_subspace (char *name)
+is_defined_subspace (const char *name)
 {
   sd_chain_struct *space_chain;
   ssd_chain_struct *subspace_chain;
This page took 0.030247 seconds and 4 git commands to generate.