2004-02-17 David Mosberger <davidm@hpl.hp.com>
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index 6102091a0fd625cf2186ec90b1f46e9d8efa1c3e..ce23210bec2900ba4d8e1733fc762194493dd719 100644 (file)
@@ -165,11 +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->objfile_obstack, 0, 0, xmalloc,
-                                 xfree);
-      obstack_specify_allocation (&objfile->symbol_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);
     }
 
@@ -233,17 +231,51 @@ 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;
+    }
+  objfile->ei.deprecated_entry_file_lowpc = INVALID_ENTRY_LOWPC;
+  objfile->ei.deprecated_entry_file_highpc = INVALID_ENTRY_HIGHPC;
+  objfile->ei.entry_func_lowpc = INVALID_ENTRY_LOWPC;
+  objfile->ei.entry_func_highpc = INVALID_ENTRY_HIGHPC;
+  objfile->ei.main_func_lowpc = INVALID_ENTRY_LOWPC;
+  objfile->ei.main_func_highpc = INVALID_ENTRY_HIGHPC;
+}
+
+/* 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])));
 
   {
@@ -251,11 +283,6 @@ 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;
-    MSYMBOL_TYPE (m) = mst_unknown;
     SYMBOL_INIT_LANGUAGE_SPECIFIC (m, language_unknown);
   }
 }
@@ -339,8 +366,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
-   objfile_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:
@@ -430,8 +457,6 @@ free_objfile (struct objfile *objfile)
   if (objfile->demangled_names_hash)
     htab_delete (objfile->demangled_names_hash);
   obstack_free (&objfile->objfile_obstack, 0);
-  obstack_free (&objfile->symbol_obstack, 0);
-
   xmfree (objfile->md, objfile);
   objfile = NULL;
 }
This page took 0.025453 seconds and 4 git commands to generate.