2004-10-30 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index dd18e73862590014a22fdd379190f32c1d067ad2..a4aa652f2581c2dc39203c863566b5b7bdbcffab 100644 (file)
@@ -93,7 +93,7 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
   section.ovly_mapped = 0;
   section.addr = bfd_section_vma (abfd, asect);
   section.endaddr = section.addr + bfd_section_size (abfd, asect);
-  obstack_grow (&objfile->psymbol_obstack, (char *) &section, sizeof (section));
+  obstack_grow (&objfile->objfile_obstack, (char *) &section, sizeof (section));
   objfile->sections_end = (struct obj_section *) (((unsigned long) objfile->sections_end) + 1);
 }
 
@@ -119,13 +119,13 @@ build_objfile_section_table (struct objfile *objfile)
   /* objfile->sections can be already set when reading a mapped symbol
      file.  I believe that we do need to rebuild the section table in
      this case (we rebuild other things derived from the bfd), but we
-     can't free the old one (it's in the psymbol_obstack).  So we just
+     can't free the old one (it's in the objfile_obstack).  So we just
      waste some memory.  */
 
   objfile->sections_end = 0;
   bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *) objfile);
   objfile->sections = (struct obj_section *)
-    obstack_finish (&objfile->psymbol_obstack);
+    obstack_finish (&objfile->objfile_obstack);
   objfile->sections_end = objfile->sections + (unsigned long) objfile->sections_end;
   return (0);
 }
@@ -165,13 +165,9 @@ allocate_objfile (bfd *abfd, int flags)
       objfile->md = NULL;
       objfile->psymbol_cache = bcache_xmalloc ();
       objfile->macro_cache = bcache_xmalloc ();
-      obstack_specify_allocation (&objfile->psymbol_obstack, 0, 0, xmalloc,
-                                 xfree);
-      obstack_specify_allocation (&objfile->symbol_obstack, 0, 0, xmalloc,
-                                 xfree);
-      obstack_specify_allocation (&objfile->objfile_obstack, 0, 0, xmalloc,
-                                 xfree);
-
+      /* We could use obstack_specify_allocation here instead, but
+        gdb_obstack.h specifies the alloc/dealloc functions.  */
+      obstack_init (&objfile->objfile_obstack);
       terminate_minimal_symbol_table (objfile);
     }
 
@@ -184,11 +180,11 @@ allocate_objfile (bfd *abfd, int flags)
   objfile->obfd = abfd;
   if (objfile->name != NULL)
     {
-      xmfree (objfile->md, objfile->name);
+      xfree (objfile->name);
     }
   if (abfd != NULL)
     {
-      objfile->name = mstrsave (objfile->md, bfd_get_filename (abfd));
+      objfile->name = xstrdup (bfd_get_filename (abfd));
       objfile->mtime = bfd_get_mtime (abfd);
 
       /* Build section table.  */
@@ -201,7 +197,7 @@ allocate_objfile (bfd *abfd, int flags)
     }
   else
     {
-      objfile->name = mstrsave (objfile->md, "<<anonymous objfile>>");
+      objfile->name = xstrdup ("<<anonymous objfile>>");
     }
 
   /* Initialize the section indexes for this objfile, so that we can
@@ -235,17 +231,45 @@ allocate_objfile (bfd *abfd, int flags)
   return (objfile);
 }
 
+/* Initialize entry point information for this objfile. */
+
+void
+init_entry_point_info (struct objfile *objfile)
+{
+  /* Save startup file's range of PC addresses to help blockframe.c
+     decide where the bottom of the stack is.  */
+
+  if (bfd_get_file_flags (objfile->obfd) & EXEC_P)
+    {
+      /* Executable file -- record its entry point so we'll recognize
+         the startup file because it contains the entry point.  */
+      objfile->ei.entry_point = bfd_get_start_address (objfile->obfd);
+    }
+  else
+    {
+      /* Examination of non-executable.o files.  Short-circuit this stuff.  */
+      objfile->ei.entry_point = INVALID_ENTRY_POINT;
+    }
+}
+
+/* Get current entry point address.  */
+
+CORE_ADDR
+entry_point_address (void)
+{
+  return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
+}
 
 /* Create the terminating entry of OBJFILE's minimal symbol table.
    If OBJFILE->msymbols is zero, allocate a single entry from
-   OBJFILE->symbol_obstack; otherwise, just initialize
+   OBJFILE->objfile_obstack; otherwise, just initialize
    OBJFILE->msymbols[OBJFILE->minimal_symbol_count].  */
 void
 terminate_minimal_symbol_table (struct objfile *objfile)
 {
   if (! objfile->msymbols)
     objfile->msymbols = ((struct minimal_symbol *)
-                         obstack_alloc (&objfile->symbol_obstack,
+                         obstack_alloc (&objfile->objfile_obstack,
                                         sizeof (objfile->msymbols[0])));
 
   {
@@ -253,10 +277,7 @@ terminate_minimal_symbol_table (struct objfile *objfile)
       = &objfile->msymbols[objfile->minimal_symbol_count];
 
     memset (m, 0, sizeof (*m));
-    DEPRECATED_SYMBOL_NAME (m) = NULL;
-    SYMBOL_VALUE_ADDRESS (m) = 0;
-    MSYMBOL_INFO (m) = NULL;
-    MSYMBOL_SIZE (m) = 0;
+    /* Don't rely on these enumeration values being 0's.  */
     MSYMBOL_TYPE (m) = mst_unknown;
     SYMBOL_INIT_LANGUAGE_SPECIFIC (m, language_unknown);
   }
@@ -341,8 +362,8 @@ unlink_objfile (struct objfile *objfile)
 
 
 /* Destroy an objfile and all the symtabs and psymtabs under it.  Note
-   that as much as possible is allocated on the symbol_obstack and
-   psymbol_obstack, so that the memory can be efficiently freed.
+   that as much as possible is allocated on the objfile_obstack 
+   so that the memory can be efficiently freed.
 
    Things which we do NOT free because they are not in malloc'd memory
    or not in memory specific to the objfile include:
@@ -420,21 +441,19 @@ free_objfile (struct objfile *objfile)
   objfile_free_data (objfile);
   if (objfile->name != NULL)
     {
-      xmfree (objfile->md, objfile->name);
+      xfree (objfile->name);
     }
   if (objfile->global_psymbols.list)
-    xmfree (objfile->md, objfile->global_psymbols.list);
+    xfree (objfile->global_psymbols.list);
   if (objfile->static_psymbols.list)
-    xmfree (objfile->md, objfile->static_psymbols.list);
+    xfree (objfile->static_psymbols.list);
   /* Free the obstacks for non-reusable objfiles */
   bcache_xfree (objfile->psymbol_cache);
   bcache_xfree (objfile->macro_cache);
   if (objfile->demangled_names_hash)
     htab_delete (objfile->demangled_names_hash);
-  obstack_free (&objfile->psymbol_obstack, 0);
-  obstack_free (&objfile->symbol_obstack, 0);
   obstack_free (&objfile->objfile_obstack, 0);
-  xmfree (objfile->md, objfile);
+  xfree (objfile);
   objfile = NULL;
 }
 
@@ -536,12 +555,13 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
                  SYMBOL_VALUE_ADDRESS (sym) +=
                    ANOFFSET (delta, SYMBOL_SECTION (sym));
                }
-#ifdef MIPS_EFI_SYMBOL_NAME
+#ifdef MDEBUG_EFI_SYMBOL_NAME
              /* Relocate Extra Function Info for ecoff.  */
 
              else if (SYMBOL_CLASS (sym) == LOC_CONST
                       && SYMBOL_DOMAIN (sym) == LABEL_DOMAIN
-                      && strcmp (DEPRECATED_SYMBOL_NAME (sym), MIPS_EFI_SYMBOL_NAME) == 0)
+                      && strcmp (DEPRECATED_SYMBOL_NAME (sym),
+                                 MDEBUG_EFI_SYMBOL_NAME) == 0)
                ecoff_relocate_efi (sym, ANOFFSET (delta,
                                                   s->block_line_section));
 #endif
@@ -626,24 +646,6 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
       }
   }
 
-  if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC)
-    {
-      objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-      objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-    }
-
-  if (objfile->ei.deprecated_entry_file_lowpc != INVALID_ENTRY_LOWPC)
-    {
-      objfile->ei.deprecated_entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-      objfile->ei.deprecated_entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-    }
-
-  if (objfile->ei.main_func_lowpc != INVALID_ENTRY_LOWPC)
-    {
-      objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-      objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-    }
-
   /* Relocate breakpoints as necessary, after things are relocated. */
   breakpoint_re_set ();
 }
This page took 0.038308 seconds and 4 git commands to generate.