* configure.tgt: Mark v850 as multi-arched.
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 985d80bec175b1b14991ce31ac45c3a523be11de..d087b1fe4c79c5296dac77ec5133ef6e90932db3 100644 (file)
@@ -120,6 +120,8 @@ static void cashier_psymtab (struct partial_symtab *);
 
 bfd *symfile_bfd_open (char *);
 
+int get_section_index (struct objfile *, char *);
+
 static void find_sym_fns (struct objfile *);
 
 static void decrement_reading_symtab (void *);
@@ -537,6 +539,34 @@ default_symfile_offsets (struct objfile *objfile,
   if (sect) 
     objfile->sect_index_rodata = sect->index;
 
+  /* This is where things get really weird...  We MUST have valid
+     indices for the various sect_index_* members or gdb will abort.
+     So if for example, there is no ".text" section, we have to
+     accomodate that.  Except when explicitly adding symbol files at
+     some address, section_offsets contains nothing but zeros, so it
+     doesn't matter which slot in section_offsets the individual
+     sect_index_* members index into.  So if they are all zero, it is
+     safe to just point all the currently uninitialized indices to the
+     first slot. */
+
+  for (i = 0; i < objfile->num_sections; i++)
+    {
+      if (ANOFFSET (objfile->section_offsets, i) != 0)
+       {
+         break;
+       }
+    }
+  if (i == objfile->num_sections)
+    {
+      if (objfile->sect_index_text == -1)
+       objfile->sect_index_text = 0;
+      if (objfile->sect_index_data == -1)
+       objfile->sect_index_data = 0;
+      if (objfile->sect_index_bss == -1)
+       objfile->sect_index_bss = 0;
+      if (objfile->sect_index_rodata == -1)
+       objfile->sect_index_rodata = 0;
+    }
 }
 
 /* Process a symbol file, as either the main file or as a dynamically
@@ -861,9 +891,6 @@ symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs,
       syms_from_objfile (objfile, addrs, mainline, from_tty);
     }
 
-  if (objfile->sf == NULL)
-    return objfile;    /* No symbols. */
-
   /* We now have at least a partial symbol table.  Check to see if the
      user requested that all symbols be read on initial access via either
      the gdb startup command line or on a per symbol file basis.  Expand
@@ -897,6 +924,9 @@ symbol_file_add (char *name, int from_tty, struct section_addr_info *addrs,
        }
     }
 
+  if (objfile->sf == NULL)
+    return objfile;    /* No symbols. */
+
   new_symfile_objfile (objfile, mainline, from_tty);
 
   if (target_new_objfile_hook)
@@ -1115,6 +1145,18 @@ symfile_bfd_open (char *name)
   return (sym_bfd);
 }
 
+/* Return the section index for the given section name. Return -1 if
+   the section was not found. */
+int
+get_section_index (struct objfile *objfile, char *section_name)
+{
+  asection *sect = bfd_get_section_by_name (objfile->obfd, section_name);
+  if (sect)
+    return sect->index;
+  else
+    return -1;
+}
+
 /* Link a new symtab_fns into the global symtab_fns list.  Called on gdb
    startup by the _initialize routine in each object file format reader,
    to register information about each format the the reader is prepared
@@ -1699,6 +1741,7 @@ reread_symbols (void)
 
              /* Free the obstacks for non-reusable objfiles */
              free_bcache (&objfile->psymbol_cache);
+             free_bcache (&objfile->macro_cache);
              obstack_free (&objfile->psymbol_obstack, 0);
              obstack_free (&objfile->symbol_obstack, 0);
              obstack_free (&objfile->type_obstack, 0);
@@ -1724,6 +1767,8 @@ reread_symbols (void)
                 it is empty.  */
              obstack_specify_allocation (&objfile->psymbol_cache.cache, 0, 0,
                                          xmalloc, xfree);
+             obstack_specify_allocation (&objfile->macro_cache.cache, 0, 0,
+                                         xmalloc, xfree);
              obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0,
                                          xmalloc, xfree);
              obstack_specify_allocation (&objfile->symbol_obstack, 0, 0,
@@ -1817,8 +1862,9 @@ add_filename_language (char *ext, enum language lang)
   if (fl_table_next >= fl_table_size)
     {
       fl_table_size += 10;
-      filename_language_table = xrealloc (filename_language_table,
-                                         fl_table_size);
+      filename_language_table = 
+       xrealloc (filename_language_table,
+                 fl_table_size * sizeof (*filename_language_table));
     }
 
   filename_language_table[fl_table_next].ext = xstrdup (ext);
@@ -3233,7 +3279,7 @@ Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
 ADDR is the starting address of the file's text.\n\
 The optional arguments are section-name section-address pairs and\n\
 should be specified if the data and bss segments are not contiguous\n\
-with the text. SECT is a section name to be loaded at SECT_ADDR.",
+with the text.  SECT is a section name to be loaded at SECT_ADDR.",
               &cmdlist);
   set_cmd_completer (c, filename_completer);
 
This page took 0.025543 seconds and 4 git commands to generate.