* objfiles.c (add_to_objfile_sections): Remove outdated comments.
authorDoug Evans <dje@google.com>
Tue, 21 Feb 2012 06:55:36 +0000 (06:55 +0000)
committerDoug Evans <dje@google.com>
Tue, 21 Feb 2012 06:55:36 +0000 (06:55 +0000)
Rename objfile_p_char parameter to objfilep.
(build_objfile_section_table): Result is now void.  All callers
updated.
* objfiles.h (struct objfile): Tweak comments, whitespace.
(build_objfile_section_table): Update.

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/symfile.c

index e09310a..52e0d74 100644 (file)
@@ -1,5 +1,12 @@
 2012-02-20  Doug Evans  <dje@google.com>
 
+       * objfiles.c (add_to_objfile_sections): Remove outdated comments.
+       Rename objfile_p_char parameter to objfilep.
+       (build_objfile_section_table): Result is now void.  All callers
+       updated.
+       * objfiles.h (struct objfile): Tweak comments, whitespace.
+       (build_objfile_section_table): Update.
+
        * elfread.c (elf_symfile_segments): Fix warning text.
 
 2012-02-20  Tom Tromey  <tromey@redhat.com>
index 1cf5aee..e29b3a7 100644 (file)
@@ -105,13 +105,6 @@ get_objfile_pspace_data (struct program_space *pspace)
   return info;
 }
 
-/* Records whether any objfiles appeared or disappeared since we last updated
-   address to obj section map.  */
-
-/* Locate all mappable sections of a BFD file.
-   objfile_p_char is a char * to get it through
-   bfd_map_over_sections; we cast it back to its proper type.  */
-
 /* Called via bfd_map_over_sections to build up the section table that
    the objfile references.  The objfile contains pointers to the start
    of the table (objfile->sections) and to the first location after
@@ -119,19 +112,18 @@ get_objfile_pspace_data (struct program_space *pspace)
 
 static void
 add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
-                        void *objfile_p_char)
+                        void *objfilep)
 {
-  struct objfile *objfile = (struct objfile *) objfile_p_char;
+  struct objfile *objfile = (struct objfile *) objfilep;
   struct obj_section section;
   flagword aflag;
 
   aflag = bfd_get_section_flags (abfd, asect);
-
   if (!(aflag & SEC_ALLOC))
     return;
-
-  if (0 == bfd_section_size (abfd, asect))
+  if (bfd_section_size (abfd, asect) == 0)
     return;
+
   section.objfile = objfile;
   section.the_bfd_section = asect;
   section.ovly_mapped = 0;
@@ -142,11 +134,9 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
 }
 
 /* Builds a section table for OBJFILE.
-   Returns 0 if OK, 1 on error (in which case bfd_error contains the
-   error).
 
    Note that while we are building the table, which goes into the
-   psymbol obstack, we hijack the sections_end pointer to instead hold
+   objfile obstack, we hijack the sections_end pointer to instead hold
    a count of the number of sections.  When bfd_map_over_sections
    returns, this count is used to compute the pointer to the end of
    the sections table, which then overwrites the count.
@@ -154,10 +144,10 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
    Also note that the OFFSET and OVLY_MAPPED in each table entry
    are initialized to zero.
 
-   Also note that if anything else writes to the psymbol obstack while
+   Also note that if anything else writes to the objfile obstack while
    we are building the table, we're pretty much hosed.  */
 
-int
+void
 build_objfile_section_table (struct objfile *objfile)
 {
   objfile->sections_end = 0;
@@ -165,7 +155,6 @@ build_objfile_section_table (struct objfile *objfile)
                         add_to_objfile_sections, (void *) objfile);
   objfile->sections = obstack_finish (&objfile->objfile_obstack);
   objfile->sections_end = objfile->sections + (size_t) objfile->sections_end;
-  return (0);
 }
 
 /* Given a pointer to an initialized bfd (ABFD) and some flag bits
@@ -216,12 +205,7 @@ allocate_objfile (bfd *abfd, int flags)
       objfile->mtime = bfd_get_mtime (abfd);
 
       /* Build section table.  */
-
-      if (build_objfile_section_table (objfile))
-       {
-         error (_("Can't find the file sections in `%s': %s"),
-                objfile->name, bfd_errmsg (bfd_get_error ()));
-       }
+      build_objfile_section_table (objfile);
     }
   else
     {
index aba1791..d5c807f 100644 (file)
@@ -327,13 +327,13 @@ struct objfile
     unsigned num_data;
 
     /* Set of relocation offsets to apply to each section.
-       Currently on the objfile_obstack (which makes no sense, but I'm
-       not sure it's harming anything).
+       The table is indexed by the_bfd_section->index, thus it is generally
+       as large as the number of sections in the binary.
+       The table is stored on the objfile_obstack.
 
        These offsets indicate that all symbols (including partial and
        minimal symbols) which have been read have been relocated by this
-       much.  Symbols which are yet to be read need to be relocated by
-       it.  */
+       much.  Symbols which are yet to be read need to be relocated by it.  */
 
     struct section_offsets *section_offsets;
     int num_sections;
@@ -354,12 +354,11 @@ struct objfile
        among other things, is used to map pc addresses into sections.
        SECTIONS points to the first entry in the table, and
        SECTIONS_END points to the first location past the last entry
-       in the table.  Currently the table is stored on the
-       objfile_obstack (which makes no sense, but I'm not sure it's
-       harming anything).  */
+       in the table.  The table is stored on the objfile_obstack.
+       There is no particular order to the sections in this table, and it
+       only contains sections we care about (e.g. non-empty, SEC_ALLOC).  */
 
-    struct obj_section
-     *sections, *sections_end;
+    struct obj_section *sections, *sections_end;
 
     /* GDB allows to have debug symbols in separate object files.  This is
        used by .gnu_debuglink, ELF build id note and Mach-O OSO.
@@ -381,7 +380,7 @@ struct objfile
     struct objfile *separate_debug_objfile_link;
 
     /* Place to stash various statistics about this objfile.  */
-      OBJSTATS;
+    OBJSTATS;
 
     /* A linked list of symbols created when reading template types or
        function templates.  These symbols are not stored in any symbol
@@ -450,7 +449,7 @@ extern int entry_point_address_query (CORE_ADDR *entry_p);
 
 extern CORE_ADDR entry_point_address (void);
 
-extern int build_objfile_section_table (struct objfile *);
+extern void build_objfile_section_table (struct objfile *);
 
 extern void terminate_minimal_symbol_table (struct objfile *objfile);
 
index 11ddfe8..ad46748 100644 (file)
@@ -2605,14 +2605,9 @@ reread_symbols (void)
 
          /* obstack_init also initializes the obstack so it is
             empty.  We could use obstack_specify_allocation but
-            gdb_obstack.h specifies the alloc/dealloc
-            functions.  */
+            gdb_obstack.h specifies the alloc/dealloc functions.  */
          obstack_init (&objfile->objfile_obstack);
-         if (build_objfile_section_table (objfile))
-           {
-             error (_("Can't find the file sections in `%s': %s"),
-                    objfile->name, bfd_errmsg (bfd_get_error ()));
-           }
+         build_objfile_section_table (objfile);
          terminate_minimal_symbol_table (objfile);
 
          /* We use the same section offsets as from last time.  I'm not