ld/plugins: avoid shadowing a C library symbol
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 73e436f4f62fe5f3d5d0ef24f4e9cdf6882788fa..307debd2824fa763320e6f18af1e47c45b032095 100644 (file)
@@ -536,9 +536,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
     perror_with_name (objfile_name (objfile));
 
   /* Size the symbol table.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
+  init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
   symbol_size = DBX_SYMBOL_SIZE (objfile);
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
@@ -749,7 +747,8 @@ static char *stringtab_global;
 /* These variables are used to control fill_symbuf when the stabs
    symbols are not contiguous (as may be the case when a COFF file is
    linked using --split-by-reloc).  */
-static struct stab_section_list *symbuf_sections;
+static const std::vector<asection *> *symbuf_sections;
+static size_t sect_idx;
 static unsigned int symbuf_left;
 static unsigned int symbuf_read;
 
@@ -785,13 +784,13 @@ fill_symbuf (bfd *sym_bfd)
     {
       if (symbuf_left <= 0)
        {
-         file_ptr filepos = symbuf_sections->section->filepos;
+         file_ptr filepos = (*symbuf_sections)[sect_idx]->filepos;
 
          if (bfd_seek (sym_bfd, filepos, SEEK_SET) != 0)
            perror_with_name (bfd_get_filename (sym_bfd));
-         symbuf_left = bfd_section_size (sym_bfd, symbuf_sections->section);
+         symbuf_left = bfd_section_size (sym_bfd, (*symbuf_sections)[sect_idx]);
          symbol_table_offset = filepos - symbuf_read;
-         symbuf_sections = symbuf_sections->next;
+         ++sect_idx;
        }
 
       count = symbuf_left;
@@ -2013,7 +2012,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
          address, set it to our starting address.  Take care to not set our
          own ending address to our starting address.  */
 
-      for (partial_symtab *p1 : objfile_psymtabs (objfile))
+      for (partial_symtab *p1 : objfile->psymtabs ())
        if (!p1->text_high_valid && p1->text_low_valid && p1 != pst)
          p1->set_text_high (pst->raw_text_low ());
     }
@@ -2025,9 +2024,8 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   pst->number_of_dependencies = number_dependencies;
   if (number_dependencies)
     {
-      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
-                                    struct partial_symtab *,
-                                    number_dependencies);
+      pst->dependencies
+       = objfile->partial_symtabs->allocate_dependencies (number_dependencies);
       memcpy (pst->dependencies, dependency_list,
              number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2047,7 +2045,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
       subpst->dependencies =
-       XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
+       objfile->partial_symtabs->allocate_dependencies (1);
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
@@ -2945,7 +2943,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 void
 coffstab_build_psymtabs (struct objfile *objfile,
                         CORE_ADDR textaddr, unsigned int textsize,
-                        struct stab_section_list *stabsects,
+                        const std::vector<asection *> &stabsects,
                         file_ptr stabstroffset, unsigned int stabstrsize)
 {
   int val;
@@ -2953,6 +2951,10 @@ coffstab_build_psymtabs (struct objfile *objfile,
   char *name = bfd_get_filename (sym_bfd);
   unsigned int stabsize;
 
+  /* Allocate struct to keep track of stab reading.  */
+  struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info);
+  set_objfile_data (objfile, dbx_objfile_data_key, dbx);
+
   DBX_TEXT_ADDR (objfile) = textaddr;
   DBX_TEXT_SIZE (objfile) = textsize;
 
@@ -2984,27 +2986,28 @@ coffstab_build_psymtabs (struct objfile *objfile,
   /* In a coff file, we've already installed the minimal symbols that came
      from the coff (non-stab) symbol table, so always act like an
      incremental load here.  */
-  if (stabsects->next == NULL)
+  scoped_restore save_symbuf_sections
+    = make_scoped_restore (&symbuf_sections);
+  if (stabsects.size () == 1)
     {
-      stabsize = bfd_section_size (sym_bfd, stabsects->section);
+      stabsize = bfd_section_size (sym_bfd, stabsects[0]);
       DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
-      DBX_SYMTAB_OFFSET (objfile) = stabsects->section->filepos;
+      DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
     }
   else
     {
-      struct stab_section_list *stabsect;
-
       DBX_SYMCOUNT (objfile) = 0;
-      for (stabsect = stabsects; stabsect != NULL; stabsect = stabsect->next)
+      for (asection *section : stabsects)
        {
-         stabsize = bfd_section_size (sym_bfd, stabsect->section);
+         stabsize = bfd_section_size (sym_bfd, section);
          DBX_SYMCOUNT (objfile) += stabsize / DBX_SYMBOL_SIZE (objfile);
        }
 
-      DBX_SYMTAB_OFFSET (objfile) = stabsects->section->filepos;
+      DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
 
-      symbuf_sections = stabsects->next;
-      symbuf_left = bfd_section_size (sym_bfd, stabsects->section);
+      sect_idx = 1;
+      symbuf_sections = &stabsects;
+      symbuf_left = bfd_section_size (sym_bfd, stabsects[0]);
       symbuf_read = 0;
     }
 
@@ -3035,6 +3038,12 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
   bfd *sym_bfd = objfile->obfd;
   char *name = bfd_get_filename (sym_bfd);
 
+  stabsread_new_init ();
+
+  /* Allocate struct to keep track of stab reading.  */
+  struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info);
+  set_objfile_data (objfile, dbx_objfile_data_key, dbx);
+
   /* Find the first and last text address.  dbx_symfile_read seems to
      want this.  */
   find_text_range (sym_bfd, objfile);
This page took 0.030763 seconds and 4 git commands to generate.