aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2003-02-03 20:39:41 +0000
committerJim Blandy <jimb@codesourcery.com>2003-02-03 20:39:41 +0000
commit158314526c237246cc19dd4a22fd3820694cb6df (patch)
tree408d89852e5fa04a30a1d8b29843b3466f0076c1 /gdb/objfiles.c
parentffc65945ba8548a7668003732ba1486d0aa40a81 (diff)
downloadgdb-158314526c237246cc19dd4a22fd3820694cb6df.zip
gdb-158314526c237246cc19dd4a22fd3820694cb6df.tar.gz
gdb-158314526c237246cc19dd4a22fd3820694cb6df.tar.bz2
Use a single, consistent representation for an empty minimal
symbol table in an objfile. * objfiles.c (terminate_minimal_symbol_table): New function. (allocate_objfile): Call it. * objfiles.h (terminate_minimal_symbol_table): New declaration. (ALL_MSYMBOLS): No need to test whether (objfile)->msymbols is non-NULL. * minsyms.c (lookup_minimal_symbol_by_pc_section): To see whether objfile has minimal symbols, compare minimal_symbol_count to zero, instead of comparing msymbols with NULL. * objfiles.c (have_minimal_symbols): Same. * solib-sunos.c (solib_add_common_symbols): Call terminate_minimal_symbol_table. * symfile.c (reread_symbols): Same.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d62b28f..16d8527 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -281,6 +281,8 @@ allocate_objfile (bfd *abfd, int flags)
obstack_specify_allocation (&objfile->type_obstack, 0, 0, xmalloc,
xfree);
flags &= ~OBJF_MAPPED;
+
+ terminate_minimal_symbol_table (objfile);
}
/* Update the per-objfile information that comes from the bfd, ensuring
@@ -333,6 +335,33 @@ allocate_objfile (bfd *abfd, int flags)
return (objfile);
}
+
+/* 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->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,
+ sizeof (objfile->msymbols[0])));
+
+ {
+ struct minimal_symbol *m
+ = &objfile->msymbols[objfile->minimal_symbol_count];
+
+ memset (m, 0, sizeof (*m));
+ SYMBOL_NAME (m) = NULL;
+ SYMBOL_VALUE_ADDRESS (m) = 0;
+ MSYMBOL_INFO (m) = NULL;
+ MSYMBOL_TYPE (m) = mst_unknown;
+ SYMBOL_INIT_LANGUAGE_SPECIFIC (m, language_unknown);
+ }
+}
+
+
/* Put one object file before a specified on in the global list.
This can be used to make sure an object file is destroyed before
another when using ALL_OBJFILES_SAFE to free all objfiles. */
@@ -810,7 +839,7 @@ have_minimal_symbols (void)
ALL_OBJFILES (ofp)
{
- if (ofp->msymbols != NULL)
+ if (ofp->minimal_symbol_count > 0)
{
return 1;
}