win32 typo fix
[deliverable/binutils-gdb.git] / bfd / xsym.c
index e38f9baca21bb611d2c892fe6a17a0647df79f8e..525d6d98abc1bc385acce6593fb57aca8ae7bde9 100644 (file)
@@ -1,12 +1,11 @@
 /* xSYM symbol-file support for BFD.
 /* xSYM symbol-file support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 1999-2020 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 
+/* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
+
+#include "sysdep.h"
+#include "alloca-conf.h"
 #include "xsym.h"
 #include "bfd.h"
 #include "xsym.h"
 #include "bfd.h"
-#include "sysdep.h"
 #include "libbfd.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_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_get_reloc_upper_bound               _bfd_norelocs_get_reloc_upper_bound
-#define bfd_sym_canonicalize_reloc                  _bfd_norelocs_canonicalize_reloc
-#define bfd_sym_bfd_reloc_type_lookup               _bfd_norelocs_bfd_reloc_type_lookup
-#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_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_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_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_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;
 
@@ -81,11 +91,11 @@ static unsigned long
 compute_offset (unsigned long first_page,
                unsigned long page_size,
                unsigned long entry_size,
 compute_offset (unsigned long first_page,
                unsigned long page_size,
                unsigned long entry_size,
-               unsigned long index)
+               unsigned long sym_index)
 {
   unsigned long entries_per_page = page_size / entry_size;
 {
   unsigned long entries_per_page = page_size / entry_size;
-  unsigned long page_number = first_page + (index / entries_per_page);
-  unsigned long page_offset = (index % entries_per_page) * entry_size;
+  unsigned long page_number = first_page + (sym_index / entries_per_page);
+  unsigned long page_offset = (sym_index % entries_per_page) * entry_size;
 
   return (page_number * page_size) + page_offset;
 }
 
   return (page_number * page_size) + page_offset;
 }
@@ -117,24 +127,12 @@ bfd_sym_valid (bfd *abfd)
 unsigned char *
 bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb)
 {
 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;
 
   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
 }
 
 void
@@ -527,7 +525,7 @@ bfd_sym_parse_type_table_entry_v32 (unsigned char *buf,
 int
 bfd_sym_fetch_resources_table_entry (bfd *abfd,
                                     bfd_sym_resources_table_entry *entry,
 int
 bfd_sym_fetch_resources_table_entry (bfd *abfd,
                                     bfd_sym_resources_table_entry *entry,
-                                    unsigned long index)
+                                    unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
   unsigned long offset;
@@ -539,7 +537,7 @@ bfd_sym_fetch_resources_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -563,7 +561,7 @@ bfd_sym_fetch_resources_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -578,7 +576,7 @@ bfd_sym_fetch_resources_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_modules_table_entry (bfd *abfd,
                                   bfd_sym_modules_table_entry *entry,
 int
 bfd_sym_fetch_modules_table_entry (bfd *abfd,
                                   bfd_sym_modules_table_entry *entry,
-                                  unsigned long index)
+                                  unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
   unsigned long offset;
@@ -590,7 +588,7 @@ bfd_sym_fetch_modules_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -614,7 +612,7 @@ bfd_sym_fetch_modules_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -629,7 +627,7 @@ bfd_sym_fetch_modules_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_file_references_table_entry (bfd *abfd,
                                           bfd_sym_file_references_table_entry *entry,
 int
 bfd_sym_fetch_file_references_table_entry (bfd *abfd,
                                           bfd_sym_file_references_table_entry *entry,
-                                          unsigned long index)
+                                          unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
   unsigned long offset;
@@ -641,7 +639,7 @@ bfd_sym_fetch_file_references_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -664,7 +662,7 @@ bfd_sym_fetch_file_references_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -679,7 +677,7 @@ bfd_sym_fetch_file_references_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
                                             bfd_sym_contained_modules_table_entry *entry,
 int
 bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
                                             bfd_sym_contained_modules_table_entry *entry,
-                                            unsigned long index)
+                                            unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
   unsigned long offset;
@@ -691,7 +689,7 @@ bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -714,7 +712,7 @@ bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -729,7 +727,7 @@ bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
                                               bfd_sym_contained_variables_table_entry *entry,
 int
 bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
                                               bfd_sym_contained_variables_table_entry *entry,
-                                              unsigned long index)
+                                              unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
   unsigned long offset;
@@ -741,7 +739,7 @@ bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -764,7 +762,7 @@ bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -779,7 +777,7 @@ bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
                                                bfd_sym_contained_statements_table_entry *entry,
 int
 bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
                                                bfd_sym_contained_statements_table_entry *entry,
-                                               unsigned long index)
+                                               unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
   unsigned long offset;
@@ -791,7 +789,7 @@ bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -814,7 +812,7 @@ bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -829,7 +827,7 @@ bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
                                            bfd_sym_contained_labels_table_entry *entry,
 int
 bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
                                            bfd_sym_contained_labels_table_entry *entry,
-                                           unsigned long index)
+                                           unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
   unsigned long offset;
@@ -841,7 +839,7 @@ bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -864,7 +862,7 @@ bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -879,7 +877,7 @@ bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
                                           bfd_sym_contained_types_table_entry *entry,
 int
 bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
                                           bfd_sym_contained_types_table_entry *entry,
-                                          unsigned long index)
+                                          unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
   unsigned long offset;
@@ -891,7 +889,7 @@ bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -914,7 +912,7 @@ bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -929,7 +927,7 @@ bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
                                                 bfd_sym_file_references_index_table_entry *entry,
 int
 bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
                                                 bfd_sym_file_references_index_table_entry *entry,
-                                                unsigned long index)
+                                                unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
   unsigned long offset;
@@ -941,7 +939,7 @@ bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -964,7 +962,7 @@ bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -979,7 +977,7 @@ bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_constant_pool_entry (bfd *abfd,
                                   bfd_sym_constant_pool_entry *entry,
 int
 bfd_sym_fetch_constant_pool_entry (bfd *abfd,
                                   bfd_sym_constant_pool_entry *entry,
-                                  unsigned long index)
+                                  unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
   unsigned long offset;
@@ -991,7 +989,7 @@ bfd_sym_fetch_constant_pool_entry (bfd *abfd,
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return -1;
 
   switch (sdata->version)
     return -1;
 
   switch (sdata->version)
@@ -1014,7 +1012,7 @@ bfd_sym_fetch_constant_pool_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -1029,7 +1027,7 @@ bfd_sym_fetch_constant_pool_entry (bfd *abfd,
 int
 bfd_sym_fetch_type_table_entry (bfd *abfd,
                                bfd_sym_type_table_entry *entry,
 int
 bfd_sym_fetch_type_table_entry (bfd *abfd,
                                bfd_sym_type_table_entry *entry,
-                               unsigned long index)
+                               unsigned long sym_index)
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
   unsigned long offset;
 {
   void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
   unsigned long offset;
@@ -1061,7 +1059,7 @@ bfd_sym_fetch_type_table_entry (bfd *abfd,
 
   offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
                           sdata->header.dshb_page_size,
 
   offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
                           sdata->header.dshb_page_size,
-                          entry_size, index);
+                          entry_size, sym_index);
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
 
   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
     return -1;
@@ -1079,10 +1077,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;
@@ -1121,7 +1117,7 @@ bfd_sym_fetch_type_information_table_entry (bfd *abfd,
 int
 bfd_sym_fetch_type_table_information (bfd *abfd,
                                      bfd_sym_type_information_table_entry *entry,
 int
 bfd_sym_fetch_type_table_information (bfd *abfd,
                                      bfd_sym_type_information_table_entry *entry,
-                                     unsigned long index)
+                                     unsigned long sym_index)
 {
   bfd_sym_type_table_entry tindex;
   bfd_sym_data_struct *sdata = NULL;
 {
   bfd_sym_type_table_entry tindex;
   bfd_sym_data_struct *sdata = NULL;
@@ -1131,10 +1127,10 @@ bfd_sym_fetch_type_table_information (bfd *abfd,
 
   if (sdata->header.dshb_tte.dti_object_count <= 99)
     return -1;
 
   if (sdata->header.dshb_tte.dti_object_count <= 99)
     return -1;
-  if (index < 100)
+  if (sym_index < 100)
     return -1;
 
     return -1;
 
-  if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
+  if (bfd_sym_fetch_type_table_entry (abfd, &tindex, sym_index - 100) < 0)
     return -1;
   if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
     return -1;
     return -1;
   if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
     return -1;
@@ -1143,30 +1139,30 @@ bfd_sym_fetch_type_table_information (bfd *abfd,
 }
 
 const unsigned char *
 }
 
 const unsigned char *
-bfd_sym_symbol_name (bfd *abfd, unsigned long index)
+bfd_sym_symbol_name (bfd *abfd, unsigned long sym_index)
 {
   bfd_sym_data_struct *sdata = NULL;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
 {
   bfd_sym_data_struct *sdata = NULL;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
 
-  if (index == 0)
+  if (sym_index == 0)
     return (const unsigned char *) "";
 
     return (const unsigned char *) "";
 
-  index *= 2;
-  if ((index / sdata->header.dshb_page_size)
+  sym_index *= 2;
+  if ((sym_index / sdata->header.dshb_page_size)
       > sdata->header.dshb_nte.dti_page_count)
     return (const unsigned char *) "\09[INVALID]";
 
       > sdata->header.dshb_nte.dti_page_count)
     return (const unsigned char *) "\09[INVALID]";
 
-  return (const unsigned char *) sdata->name_table + index;
+  return (const unsigned char *) sdata->name_table + sym_index;
 }
 
 const unsigned char *
 }
 
 const unsigned char *
-bfd_sym_module_name (bfd *abfd, unsigned long index)
+bfd_sym_module_name (bfd *abfd, unsigned long sym_index)
 {
   bfd_sym_modules_table_entry entry;
 
 {
   bfd_sym_modules_table_entry entry;
 
-  if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
+  if (bfd_sym_fetch_modules_table_entry (abfd, &entry, sym_index) < 0)
     return (const unsigned char *) "\09[INVALID]";
 
   return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
     return (const unsigned char *) "\09[INVALID]";
 
   return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
@@ -1641,7 +1637,7 @@ bfd_sym_print_type_information (bfd *abfd,
                       bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
                       &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
          }
                       bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
                       &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
          }
-       fprintf (f, " (TTE %lu)", value);
+       fprintf (f, " (TTE %lu)", (unsigned long) value);
        break;
       }
 
        break;
       }
 
@@ -1702,13 +1698,13 @@ bfd_sym_print_type_information (bfd *abfd,
          fprintf (f, "union (0x%x) of ", type);
 
        bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
          fprintf (f, "union (0x%x) of ", type);
 
        bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
-       fprintf (f, "%lu elements: ", nrec);
+       fprintf (f, "%lu elements: ", (unsigned long) nrec);
 
        for (i = 0; i < nrec; i++)
          {
            bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
            fprintf (f, "\n                ");
 
        for (i = 0; i < nrec; i++)
          {
            bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
            fprintf (f, "\n                ");
-           fprintf (f, "offset %lu: ", eloff);
+           fprintf (f, "offset %lu: ", (unsigned long) eloff);
            bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
          }
        break;
            bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
          }
        break;
@@ -1736,7 +1732,7 @@ bfd_sym_print_type_information (bfd *abfd,
                 bfd_sym_symbol_name (abfd, value)[0],
                 &bfd_sym_symbol_name (abfd, value)[1]);
 
                 bfd_sym_symbol_name (abfd, value)[0],
                 &bfd_sym_symbol_name (abfd, value)[1]);
 
-      fprintf (f, " (NTE %lu) with type ", value);
+      fprintf (f, " (NTE %lu) with type ", (unsigned long) value);
       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
       break;
     }
       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
       break;
     }
@@ -1800,18 +1796,9 @@ bfd_sym_print_type_information_table_entry (bfd *abfd,
 
   fprintf (f, "\n            ");
 
 
   fprintf (f, "\n            ");
 
-  buf = alloca (entry->physical_size);
-  if (buf == NULL)
-    {
-      fprintf (f, "[ERROR]\n");
-      return;
-    }
-  if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
-    {
-      fprintf (f, "[ERROR]\n");
-      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");
       return;
     {
       fprintf (f, "[ERROR]\n");
       return;
@@ -1833,6 +1820,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
@@ -1856,24 +1844,24 @@ bfd_sym_display_name_table_entry (bfd *abfd,
                                  FILE *f,
                                  unsigned char *entry)
 {
                                  FILE *f,
                                  unsigned char *entry)
 {
-  unsigned long index;
+  unsigned long sym_index;
   unsigned long offset;
   bfd_sym_data_struct *sdata = NULL;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
   unsigned long offset;
   bfd_sym_data_struct *sdata = NULL;
 
   BFD_ASSERT (bfd_sym_valid (abfd));
   sdata = abfd->tdata.sym_data;
-  index = (entry - sdata->name_table) / 2;
+  sym_index = (entry - sdata->name_table) / 2;
 
   if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
     {
       unsigned short length = bfd_getb16 (entry + 2);
 
   if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
     {
       unsigned short length = bfd_getb16 (entry + 2);
-      fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
+      fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, length, entry + 4);
       offset = 2 + length + 1;
     }
   else
     {
       if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
       offset = 2 + length + 1;
     }
   else
     {
       if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
-       fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
+       fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, entry[0], entry + 1);
 
       if (sdata->version >= BFD_SYM_VERSION_3_4)
        offset = entry[0] + 2;
 
       if (sdata->version >= BFD_SYM_VERSION_3_4)
        offset = entry[0] + 2;
@@ -2175,7 +2163,7 @@ void
 bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
 {
   unsigned long i;
 bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
 {
   unsigned long i;
-  bfd_sym_type_table_entry index;
+  bfd_sym_type_table_entry sym_index;
   bfd_sym_type_information_table_entry entry;
   bfd_sym_data_struct *sdata = NULL;
 
   bfd_sym_type_information_table_entry entry;
   bfd_sym_data_struct *sdata = NULL;
 
@@ -2193,13 +2181,13 @@ bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
 
   for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
     {
 
   for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
     {
-      if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
+      if (bfd_sym_fetch_type_table_entry (abfd, &sym_index, i - 100) < 0)
        fprintf (f, " [%8lu] [INVALID]\n", i);
       else
        {
        fprintf (f, " [%8lu] [INVALID]\n", i);
       else
        {
-         fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
+         fprintf (f, " [%8lu] (TINFO %lu) ", i, sym_index);
 
 
-         if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
+         if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, sym_index) < 0)
            fprintf (f, "[INVALID]");
          else
            bfd_sym_print_type_information_table_entry (abfd, f, &entry);
            fprintf (f, "[INVALID]");
          else
            bfd_sym_print_type_information_table_entry (abfd, f, &entry);
@@ -2227,7 +2215,7 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   if (mdata->name_table == NULL)
     return -1;
 
   if (mdata->name_table == NULL)
     return -1;
 
-  bfdsec = bfd_make_section_anyway (abfd, name);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
   if (bfdsec == NULL)
     return -1;
 
@@ -2237,50 +2225,38 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   bfdsec->filepos = 0;
   bfdsec->alignment_power = 0;
 
   bfdsec->filepos = 0;
   bfdsec->alignment_power = 0;
 
-  bfdsec->flags = SEC_HAS_CONTENTS;
-
   abfd->tdata.sym_data = mdata;
 
   return 0;
 }
 
   abfd->tdata.sym_data = mdata;
 
   return 0;
 }
 
-const bfd_target *
+bfd_cleanup
 bfd_sym_object_p (bfd *abfd)
 {
 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;
+  return _bfd_no_cleanup;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
 
   return NULL;
 }
 
-asymbol *
-bfd_sym_make_empty_symbol (bfd *abfd)
-{
-  return bfd_alloc (abfd, sizeof (asymbol));
-}
+#define bfd_sym_make_empty_symbol _bfd_generic_make_empty_symbol
 
 void
 bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
 
 void
 bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
@@ -2301,7 +2277,8 @@ bfd_sym_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED, asymbol **sym ATTRIBUTE
 }
 
 int
 }
 
 int
-bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, bfd_boolean exec ATTRIBUTE_UNUSED)
+bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
+                       struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   return 0;
 }
 {
   return 0;
 }
@@ -2320,6 +2297,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.  */
@@ -2333,16 +2311,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),
@@ -2350,7 +2328,7 @@ const bfd_target sym_vec =
   BFD_JUMP_TABLE_CORE (_bfd_nocore),
   BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
   BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
   BFD_JUMP_TABLE_CORE (_bfd_nocore),
   BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
   BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
-  BFD_JUMP_TABLE_RELOCS (bfd_sym),
+  BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
   BFD_JUMP_TABLE_WRITE (bfd_sym),
   BFD_JUMP_TABLE_LINK (bfd_sym),
   BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
   BFD_JUMP_TABLE_WRITE (bfd_sym),
   BFD_JUMP_TABLE_LINK (bfd_sym),
   BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
This page took 0.045937 seconds and 4 git commands to generate.