ubsan: z8k: index 10 out of bounds for type 'unsigned int const[10]'
[deliverable/binutils-gdb.git] / bfd / xsym.c
index 6d56729a1b8704035dc0f15b400eae03a35a4d56..9c714c64809f2b9c18860da07212d7e6958d9184 100644 (file)
@@ -1,6 +1,5 @@
 /* xSYM symbol-file support for BFD.
 /* xSYM symbol-file support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   Copyright (C) 1999-2020 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
 
    This file is part of BFD, the Binary File Descriptor library.
 
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "alloca-conf.h"
+/* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
+
 #include "sysdep.h"
 #include "sysdep.h"
+#include "alloca-conf.h"
 #include "xsym.h"
 #include "bfd.h"
 #include "libbfd.h"
 
 #include "xsym.h"
 #include "bfd.h"
 #include "libbfd.h"
 
-#define bfd_sym_close_and_cleanup                   _bfd_generic_close_and_cleanup
-#define bfd_sym_bfd_free_cached_info                _bfd_generic_bfd_free_cached_info
-#define bfd_sym_new_section_hook                    _bfd_generic_new_section_hook
-#define bfd_sym_bfd_is_local_label_name             bfd_generic_is_local_label_name
-#define bfd_sym_bfd_is_target_special_symbol       ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
-#define bfd_sym_get_lineno                          _bfd_nosymbols_get_lineno
-#define bfd_sym_find_nearest_line                   _bfd_nosymbols_find_nearest_line
-#define bfd_sym_find_inliner_info                   _bfd_nosymbols_find_inliner_info
-#define bfd_sym_bfd_make_debug_symbol               _bfd_nosymbols_bfd_make_debug_symbol
-#define bfd_sym_read_minisymbols                    _bfd_generic_read_minisymbols
-#define bfd_sym_minisymbol_to_symbol                _bfd_generic_minisymbol_to_symbol
-#define bfd_sym_set_arch_mach                       _bfd_generic_set_arch_mach
-#define bfd_sym_get_section_contents                _bfd_generic_get_section_contents
-#define bfd_sym_set_section_contents                _bfd_generic_set_section_contents
+#define bfd_sym_close_and_cleanup                  _bfd_generic_close_and_cleanup
+#define bfd_sym_bfd_free_cached_info               _bfd_generic_bfd_free_cached_info
+#define bfd_sym_new_section_hook                   _bfd_generic_new_section_hook
+#define bfd_sym_bfd_is_local_label_name                    bfd_generic_is_local_label_name
+#define bfd_sym_bfd_is_target_special_symbol       _bfd_bool_bfd_asymbol_false
+#define bfd_sym_get_lineno                         _bfd_nosymbols_get_lineno
+#define bfd_sym_find_nearest_line                  _bfd_nosymbols_find_nearest_line
+#define bfd_sym_find_line                          _bfd_nosymbols_find_line
+#define bfd_sym_find_inliner_info                  _bfd_nosymbols_find_inliner_info
+#define bfd_sym_get_symbol_version_string          _bfd_nosymbols_get_symbol_version_string
+#define bfd_sym_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
+#define bfd_sym_read_minisymbols                   _bfd_generic_read_minisymbols
+#define bfd_sym_minisymbol_to_symbol               _bfd_generic_minisymbol_to_symbol
+#define bfd_sym_set_arch_mach                      _bfd_generic_set_arch_mach
+#define bfd_sym_get_section_contents               _bfd_generic_get_section_contents
+#define bfd_sym_set_section_contents               _bfd_generic_set_section_contents
 #define bfd_sym_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define bfd_sym_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
-#define bfd_sym_bfd_relax_section                   bfd_generic_relax_section
-#define bfd_sym_bfd_gc_sections                     bfd_generic_gc_sections
-#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_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
-#define bfd_sym_bfd_link_hash_table_create          _bfd_generic_link_hash_table_create
-#define bfd_sym_bfd_link_hash_table_free            _bfd_generic_link_hash_table_free
-#define bfd_sym_bfd_link_add_symbols                _bfd_generic_link_add_symbols
-#define bfd_sym_bfd_link_just_syms                  _bfd_generic_link_just_syms
+#define bfd_sym_bfd_relax_section                  bfd_generic_relax_section
+#define bfd_sym_bfd_gc_sections                            bfd_generic_gc_sections
+#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
+#define bfd_sym_bfd_link_hide_symbol               _bfd_generic_link_hide_symbol
+#define bfd_sym_bfd_define_start_stop              bfd_generic_define_start_stop
+#define bfd_sym_bfd_link_hash_table_create         _bfd_generic_link_hash_table_create
+#define bfd_sym_bfd_link_add_symbols               _bfd_generic_link_add_symbols
+#define bfd_sym_bfd_link_just_syms                 _bfd_generic_link_just_syms
 #define bfd_sym_bfd_copy_link_hash_symbol_type \
   _bfd_generic_copy_link_hash_symbol_type
 #define bfd_sym_bfd_copy_link_hash_symbol_type \
   _bfd_generic_copy_link_hash_symbol_type
-#define bfd_sym_bfd_final_link                      _bfd_generic_final_link
-#define bfd_sym_bfd_link_split_section              _bfd_generic_link_split_section
-#define bfd_sym_get_section_contents_in_window      _bfd_generic_get_section_contents_in_window
+#define bfd_sym_bfd_final_link                     _bfd_generic_final_link
+#define bfd_sym_bfd_link_split_section             _bfd_generic_link_split_section
+#define bfd_sym_get_section_contents_in_window     _bfd_generic_get_section_contents_in_window
+#define bfd_sym_bfd_link_check_relocs              _bfd_generic_link_check_relocs
 
 extern const bfd_target sym_vec;
 
 
 extern const bfd_target sym_vec;
 
@@ -1082,10 +1089,8 @@ bfd_sym_fetch_type_information_table_entry (bfd *abfd,
                                            unsigned long offset)
 {
   unsigned char buf[4];
                                            unsigned long offset)
 {
   unsigned char buf[4];
-  bfd_sym_data_struct *sdata = NULL;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
 
   BFD_ASSERT (bfd_sym_valid (abfd));
-  sdata = abfd->tdata.sym_data;
 
   if (offset == 0)
     return -1;
 
   if (offset == 0)
     return -1;
@@ -1803,7 +1808,7 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
 
   fprintf (f, "\n            ");
 
 
   fprintf (f, "\n            ");
 
-  buf = alloca (entry->physical_size);
+  buf = malloc (entry->physical_size);
   if (buf == NULL)
     {
       fprintf (f, "[ERROR]\n");
   if (buf == NULL)
     {
       fprintf (f, "[ERROR]\n");
@@ -1812,11 +1817,13 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
   if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
     {
       fprintf (f, "[ERROR]\n");
   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)
     {
       fprintf (f, "[ERROR]\n");
       return;
     }
   if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
     {
       fprintf (f, "[ERROR]\n");
+      free (buf);
       return;
     }
 
       return;
     }
 
@@ -1836,6 +1843,7 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
 
   if (offset != entry->physical_size)
     fprintf (f, "\n            [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
 
   if (offset != entry->physical_size)
     fprintf (f, "\n            [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
+  free (buf);
 }
 
 void
 }
 
 void
@@ -2248,32 +2256,26 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
 const bfd_target *
 bfd_sym_object_p (bfd *abfd)
 {
 const bfd_target *
 bfd_sym_object_p (bfd *abfd)
 {
-  struct bfd_preserve preserve;
   bfd_sym_version version = -1;
   bfd_sym_version version = -1;
+  bfd_sym_data_struct *mdata;
 
 
-  preserve.marker = NULL;
   bfd_seek (abfd, 0, SEEK_SET);
   if (bfd_sym_read_version (abfd, &version) != 0)
     goto wrong;
 
   bfd_seek (abfd, 0, SEEK_SET);
   if (bfd_sym_read_version (abfd, &version) != 0)
     goto wrong;
 
-  preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
-  if (preserve.marker == NULL
-      || ! bfd_preserve_save (abfd, &preserve))
+  mdata = (bfd_sym_data_struct *) bfd_alloc (abfd, sizeof (*mdata));
+  if (mdata == NULL)
     goto fail;
 
     goto fail;
 
-  if (bfd_sym_scan (abfd, version,
-                   (bfd_sym_data_struct *) preserve.marker) != 0)
+  if (bfd_sym_scan (abfd, version, mdata) != 0)
     goto wrong;
 
     goto wrong;
 
-  bfd_preserve_finish (abfd, &preserve);
   return abfd->xvec;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
   return abfd->xvec;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
 
   return NULL;
 }
 
@@ -2318,6 +2320,7 @@ const bfd_target sym_vec =
   0,                           /* Symbol_leading_char.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
   0,                           /* Symbol_leading_char.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
+  0,                           /* match priority.  */
   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.  */
   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.  */
@@ -2331,16 +2334,16 @@ const bfd_target sym_vec =
     _bfd_dummy_target,
   },
   {                            /* bfd_set_format.  */
     _bfd_dummy_target,
   },
   {                            /* bfd_set_format.  */
-    bfd_false,
+    _bfd_bool_bfd_false_error,
     bfd_sym_mkobject,
     bfd_sym_mkobject,
-    bfd_false,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
+    _bfd_bool_bfd_false_error,
   },
   {                            /* bfd_write_contents.  */
   },
   {                            /* bfd_write_contents.  */
-    bfd_false,
-    bfd_true,
-    bfd_false,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
+    _bfd_bool_bfd_true,
+    _bfd_bool_bfd_false_error,
+    _bfd_bool_bfd_false_error,
   },
 
   BFD_JUMP_TABLE_GENERIC (bfd_sym),
   },
 
   BFD_JUMP_TABLE_GENERIC (bfd_sym),
This page took 0.027339 seconds and 4 git commands to generate.