Add compunits range adapter to objfile
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 9649db4b9c5f3d3a4f4e7639ff3af9727c1ed701..2b75d8189fb7fe956f78d3a1e4bbf834a8e8f0b7 100644 (file)
@@ -1,5 +1,5 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
-   Copyright (C) 1987-2018 Free Software Foundation, Inc.
+   Copyright (C) 1987-2019 Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
    This file is part of GDB.
@@ -30,7 +30,7 @@
 #include "coff/internal.h"     /* Internal format of COFF symbols in BFD */
 #include "libcoff.h"           /* FIXME secret internal data from BFD */
 #include "objfiles.h"
-#include "buildsym.h"
+#include "buildsym-legacy.h"
 #include "gdb-stabs.h"
 #include "stabsread.h"
 #include "complaints.h"
@@ -565,7 +565,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   struct coff_symfile_info *info;
   bfd *abfd = objfile->obfd;
   coff_data_type *cdata = coff_data (abfd);
-  char *name = bfd_get_filename (abfd);
+  char *filename = bfd_get_filename (abfd);
   int val;
   unsigned int num_symbols;
   int symtab_offset;
@@ -637,7 +637,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
       val = init_lineno (abfd, info->min_lineno_offset,
                          info->max_lineno_offset - info->min_lineno_offset);
       if (val < 0)
-        error (_("\"%s\": error reading line numbers."), name);
+        error (_("\"%s\": error reading line numbers."), filename);
     }
 
   /* Now read the string table, all at once.  */
@@ -645,7 +645,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   make_cleanup (free_stringtab_cleanup, 0 /*ignore*/);
   val = init_stringtab (abfd, stringtab_offset);
   if (val < 0)
-    error (_("\"%s\": can't get string table"), name);
+    error (_("\"%s\": can't get string table"), filename);
 
   minimal_symbol_reader reader (objfile);
 
@@ -661,9 +661,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
   if (pe_file)
     {
-      struct minimal_symbol *msym;
-
-      ALL_OBJFILE_MSYMBOLS (objfile, msym)
+      for (minimal_symbol *msym : objfile_msymbols (objfile))
        {
          const char *name = MSYMBOL_LINKAGE_NAME (msym);
 
@@ -709,7 +707,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
        {
          error (_("The debugging information in `%s' is corrupted.\nThe "
                   "file has a `.stabs' section, but no `.stabstr' section."),
-                name);
+                filename);
        }
 
       /* FIXME: dubious.  Why can't we use something normal like
@@ -741,9 +739,9 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
       if (!debugfile.empty ())
        {
-         gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.c_str ()));
+         gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
 
-         symbol_file_add_separate (abfd.get (), debugfile.c_str (),
+         symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
                                    symfile_flags, objfile);
        }
     }
@@ -781,7 +779,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
                  struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  struct context_stack *newobj;
+  struct context_stack *newobj = nullptr;
   struct coff_symbol coff_symbol;
   struct coff_symbol *cs = &coff_symbol;
   static struct internal_syment main_sym;
@@ -804,7 +802,6 @@ coff_symtab_read (minimal_symbol_reader &reader,
   CORE_ADDR tmpaddr;
   struct minimal_symbol *msym;
 
-  buildsym_init ();
   scoped_free_pendings free_pending;
 
   /* Work around a stdio bug in SunOS4.1.1 (this makes me nervous....
@@ -878,8 +875,10 @@ coff_symtab_read (minimal_symbol_reader &reader,
          int section = cs_to_section (cs, objfile);
 
          tmpaddr = cs->c_value;
-         record_minimal_symbol (reader, cs, tmpaddr, mst_text,
-                                section, objfile);
+         /* Don't record unresolved symbols.  */
+         if (!(cs->c_secnum <= 0 && cs->c_value == 0))
+           record_minimal_symbol (reader, cs, tmpaddr, mst_text,
+                                  section, objfile);
 
          fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
          fcn_start_addr = tmpaddr;
@@ -1204,11 +1203,11 @@ coff_symtab_read (minimal_symbol_reader &reader,
   /* Patch up any opaque types (references to types that are not defined
      in the file where they are referenced, e.g. "struct foo *bar").  */
   {
-    struct compunit_symtab *cu;
-    struct symtab *s;
-
-    ALL_OBJFILE_FILETABS (objfile, cu, s)
-      patch_opaque_types (s);
+    for (compunit_symtab *cu : objfile->compunits ())
+      {
+       for (symtab *s : compunit_filetabs (cu))
+         patch_opaque_types (s);
+      }
   }
 
   coffread_objfile = NULL;
This page took 0.035143 seconds and 4 git commands to generate.