summaryrefslogtreecommitdiff
path: root/gdb/coffread.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/coffread.c')
-rw-r--r--gdb/coffread.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 94d0554dab5..56ed5aea0d1 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -47,6 +47,10 @@
extern void _initialize_coffread (void);
+/* Key for COFF-associated data. */
+
+static const struct objfile_data *coff_objfile_data_key;
+
/* The objfile we are currently reading. */
static struct objfile *coffread_objfile;
@@ -451,17 +455,15 @@ static void
coff_symfile_init (struct objfile *objfile)
{
struct dbx_symfile_info *dbx;
+ struct coff_symfile_info *coff;
/* Allocate struct to keep track of stab reading. */
dbx = XCNEW (struct dbx_symfile_info);
set_objfile_data (objfile, dbx_objfile_data_key, dbx);
/* Allocate struct to keep track of the symfile. */
- objfile->deprecated_sym_private
- = xmalloc (sizeof (struct coff_symfile_info));
-
- memset (objfile->deprecated_sym_private, 0,
- sizeof (struct coff_symfile_info));
+ coff = XCNEW (struct coff_symfile_info);
+ set_objfile_data (objfile, coff_objfile_data_key, coff);
/* COFF objects may be reordered, so set OBJF_REORDERED. If we
find this causes a significant slowdown in gdb then we could
@@ -526,7 +528,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
struct cleanup *back_to, *cleanup_minimal_symbols;
int stabstrsize;
- info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
+ info = objfile_data (objfile, coff_objfile_data_key);
dbxinfo = DBX_SYMFILE_INFO (objfile);
symfile_bfd = abfd; /* Kludge for swap routines. */
@@ -680,11 +682,6 @@ coff_new_init (struct objfile *ignore)
static void
coff_symfile_finish (struct objfile *objfile)
{
- if (objfile->deprecated_sym_private != NULL)
- {
- xfree (objfile->deprecated_sym_private);
- }
-
/* Let stabs reader clean up. */
stabsread_clear_cache ();
@@ -2199,8 +2196,19 @@ static const struct sym_fns coff_sym_fns =
&psym_functions
};
+/* Free the per-objfile COFF data. */
+
+static void
+coff_free_info (struct objfile *objfile, void *arg)
+{
+ xfree (arg);
+}
+
void
_initialize_coffread (void)
{
add_symtab_fns (&coff_sym_fns);
+
+ coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
+ coff_free_info);
}