]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/xsym.c
Use bool in bfd
[thirdparty/binutils-gdb.git] / bfd / xsym.c
index 56607f026ff03fc7a2289488dfaab1cfebcc7c2d..cac111b521fa417e99a43a60820b320d1fc6b902 100644 (file)
@@ -1,5 +1,5 @@
 /* xSYM symbol-file support for BFD.
-   Copyright (C) 1999-2018 Free Software Foundation, Inc.
+   Copyright (C) 1999-2021 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -48,6 +48,7 @@
 #define bfd_sym_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define bfd_sym_bfd_merge_sections                 bfd_generic_merge_sections
 #define bfd_sym_bfd_is_group_section               bfd_generic_is_group_section
+#define bfd_sym_bfd_group_name                     bfd_generic_group_name
 #define bfd_sym_bfd_discard_group                  bfd_generic_discard_group
 #define bfd_sym_section_already_linked             _bfd_generic_section_already_linked
 #define bfd_sym_bfd_define_common_symbol           bfd_generic_define_common_symbol
@@ -99,7 +100,7 @@ compute_offset (unsigned long first_page,
   return (page_number * page_size) + page_offset;
 }
 
-bfd_boolean
+bool
 bfd_sym_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return 1;
@@ -114,7 +115,7 @@ bfd_sym_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
   return;
 }
 
-bfd_boolean
+bool
 bfd_sym_valid (bfd *abfd)
 {
   if (abfd == NULL || abfd->xvec == NULL)
@@ -126,24 +127,12 @@ bfd_sym_valid (bfd *abfd)
 unsigned char *
 bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb)
 {
-  unsigned char *rstr;
-  long ret;
   size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
   size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
 
-  rstr = bfd_alloc (abfd, table_size);
-  if (rstr == NULL)
-    return rstr;
-
-  bfd_seek (abfd, table_offset, SEEK_SET);
-  ret = bfd_bread (rstr, table_size, abfd);
-  if (ret < 0 || (unsigned long) ret != table_size)
-    {
-      bfd_release (abfd, rstr);
-      return NULL;
-    }
-
-  return rstr;
+  if (bfd_seek (abfd, table_offset, SEEK_SET) != 0)
+    return false;
+  return _bfd_alloc_and_read (abfd, table_size, table_size);
 }
 
 void
@@ -1807,22 +1796,11 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
 
   fprintf (f, "\n            ");
 
-  buf = malloc (entry->physical_size);
-  if (buf == NULL)
-    {
-      fprintf (f, "[ERROR]\n");
-      return;
-    }
-  if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
-    {
-      fprintf (f, "[ERROR]\n");
-      free (buf);
-      return;
-    }
-  if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
+  if (bfd_seek (abfd, entry->offset, SEEK_SET) != 0
+      || (buf = _bfd_malloc_and_read (abfd, entry->physical_size,
+                                     entry->physical_size)) == NULL)
     {
       fprintf (f, "[ERROR]\n");
-      free (buf);
       return;
     }
 
@@ -2252,7 +2230,7 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   return 0;
 }
 
-const bfd_target *
+bfd_cleanup
 bfd_sym_object_p (bfd *abfd)
 {
   bfd_sym_version version = -1;
@@ -2269,7 +2247,7 @@ bfd_sym_object_p (bfd *abfd)
   if (bfd_sym_scan (abfd, version, mdata) != 0)
     goto wrong;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
@@ -2320,6 +2298,7 @@ const bfd_target sym_vec =
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
   0,                           /* match priority.  */
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* Data.  */