gas: Add md_generic_table_relax_frag
[deliverable/binutils-gdb.git] / bfd / som.c
index 640253ea9af8874e638faed5924424dc26cd0894..5145651c3d677fa4d4d94feedadbd5f1abc6989b 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -2031,12 +2031,12 @@ som_object_setup (bfd *abfd,
          || (aux_hdrp->exec_entry & 0x3) != 0
          || ! found)
        {
-         bfd_get_start_address (abfd) = aux_hdrp->exec_flags;
+         abfd->start_address = aux_hdrp->exec_flags;
          obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_entry;
        }
       else
        {
-         bfd_get_start_address (abfd) = aux_hdrp->exec_entry + current_offset;
+         abfd->start_address = aux_hdrp->exec_entry + current_offset;
          obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
        }
     }
@@ -2044,7 +2044,7 @@ som_object_setup (bfd *abfd,
   obj_som_exec_data (abfd)->version_id = file_hdrp->version_id;
 
   bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10);
-  bfd_get_symcount (abfd) = file_hdrp->symbol_total;
+  abfd->symcount = file_hdrp->symbol_total;
 
   /* Initialize the saved symbol table and string table to NULL.
      Save important offsets and sizes from the SOM header into
@@ -3309,13 +3309,16 @@ som_write_space_strings (bfd *abfd,
   /* Chunk of memory that we can use as buffer space, then throw
      away.  */
   size_t tmp_space_size = SOM_TMP_BUFSIZE;
-  char *tmp_space = xmalloc (tmp_space_size);
+  char *tmp_space = bfd_malloc (tmp_space_size);
   char *p = tmp_space;
   unsigned int strings_size = 0;
   asection *section;
   bfd_size_type amt;
   bfd_size_type res;
 
+  if (tmp_space == NULL)
+    return FALSE;
+
   /* Seek to the start of the space strings in preparation for writing
      them out.  */
   if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
@@ -3419,12 +3422,15 @@ som_write_symbol_strings (bfd *abfd,
   /* Chunk of memory that we can use as buffer space, then throw
      away.  */
   size_t tmp_space_size = SOM_TMP_BUFSIZE;
-  char *tmp_space = xmalloc (tmp_space_size);
+  char *tmp_space = bfd_malloc (tmp_space_size);
   char *p = tmp_space;
   unsigned int strings_size = 0;
   bfd_size_type amt;
   bfd_size_type res;
 
+  if (tmp_space == NULL)
+    return FALSE;
+
   /* This gets a bit gruesome because of the compilation unit.  The
      strings within the compilation unit are part of the symbol
      strings, but don't have symbol_dictionary entries.  So, manually
@@ -4792,7 +4798,7 @@ som_slurp_symbol_table (bfd *abfd)
 
   /* We modify the symbol count to record the number of BFD symbols we
      created.  */
-  bfd_get_symcount (abfd) = sym - symbase;
+  abfd->symcount = sym - symbase;
 
   /* Save our results and return success.  */
   obj_som_symtab (abfd) = symbase;
@@ -5995,6 +6001,7 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
       unsigned int hash_val;
       unsigned int len;
       unsigned char ext_len[4];
+      char *name;
 
       /* An empty chain has zero as it's file offset.  */
       hash_val = bfd_getb32 (hash_table + 4 * i);
@@ -6025,13 +6032,14 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
       len = bfd_getb32 (ext_len);
 
       /* Allocate space for the name and null terminate it too.  */
-      set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
-      if (!set->name)
+      name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
+      if (!name)
        goto error_return;
-      if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+      if (bfd_bread (name, (bfd_size_type) len, abfd) != len)
        goto error_return;
 
-      set->name[len] = 0;
+      name[len] = 0;
+      set->name = name;
 
       /* Fill in the file offset.  Note that the "location" field points
         to the SOM itself, not the ar_hdr in front of it.  */
@@ -6068,13 +6076,14 @@ som_bfd_fill_in_ar_symbols (bfd *abfd,
          len = bfd_getb32 (ext_len);
 
          /* Allocate space for the name and null terminate it too.  */
-         set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
-         if (!set->name)
+         name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
+         if (!name)
            goto error_return;
 
-         if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
+         if (bfd_bread (name, (bfd_size_type) len, abfd) != len)
            goto error_return;
-         set->name[len] = 0;
+         name[len] = 0;
+         set->name = name;
 
          /* Fill in the file offset.  Note that the "location" field points
             to the SOM itself, not the ar_hdr in front of it.  */
@@ -6128,7 +6137,7 @@ som_slurp_armap (bfd *abfd)
   /* For archives without .o files there is no symbol table.  */
   if (! CONST_STRNEQ (nextname, "/               "))
     {
-      bfd_has_map (abfd) = FALSE;
+      abfd->has_armap = FALSE;
       return TRUE;
     }
 
@@ -6198,7 +6207,7 @@ som_slurp_armap (bfd *abfd)
     return FALSE;
 
   /* Notify the generic archive code that we have a symbol map.  */
-  bfd_has_map (abfd) = TRUE;
+  abfd->has_armap = TRUE;
   return TRUE;
 }
 
@@ -6695,25 +6704,25 @@ som_write_armap (bfd *abfd,
 static bfd_boolean
 som_bfd_free_cached_info (bfd *abfd)
 {
-  asection *o;
-
-  if (bfd_get_format (abfd) != bfd_object)
-    return TRUE;
+  if (bfd_get_format (abfd) == bfd_object)
+    {
+      asection *o;
 
 #define FREE(x) if (x != NULL) { free (x); x = NULL; }
-  /* Free the native string and symbol tables.  */
-  FREE (obj_som_symtab (abfd));
-  FREE (obj_som_stringtab (abfd));
-  for (o = abfd->sections; o != NULL; o = o->next)
-    {
-      /* Free the native relocations.  */
-      o->reloc_count = (unsigned) -1;
-      FREE (som_section_data (o)->reloc_stream);
-      /* Do not free the generic relocations as they are objalloc'ed.  */
-    }
+      /* Free the native string and symbol tables.  */
+      FREE (obj_som_symtab (abfd));
+      FREE (obj_som_stringtab (abfd));
+      for (o = abfd->sections; o != NULL; o = o->next)
+       {
+         /* Free the native relocations.  */
+         o->reloc_count = (unsigned) -1;
+         FREE (som_section_data (o)->reloc_stream);
+         /* Do not free the generic relocations as they are objalloc'ed.  */
+       }
 #undef FREE
+    }
 
-  return TRUE;
+  return _bfd_generic_close_and_cleanup (abfd);
 }
 
 /* End of miscellaneous support functions.  */
@@ -6756,6 +6765,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 #define som_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define som_bfd_merge_sections                 bfd_generic_merge_sections
 #define som_bfd_is_group_section               bfd_generic_is_group_section
+#define som_bfd_group_name                     bfd_generic_group_name
 #define som_bfd_discard_group                  bfd_generic_discard_group
 #define som_section_already_linked             _bfd_generic_section_already_linked
 #define som_bfd_define_common_symbol           bfd_generic_define_common_symbol
This page took 0.03544 seconds and 4 git commands to generate.