/* Read coff symbol tables and convert to internal format, for GDB.
- Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009,
- 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1987-2005, 2007-2012 Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
This file is part of GDB.
/* The objfile we are currently reading. */
-static struct objfile *current_objfile;
+static struct objfile *coffread_objfile;
struct coff_symfile_info
{
args.resultp = §
bfd_map_over_sections (abfd, find_targ_sec, &args);
if (sect != NULL)
- addr = bfd_get_section_vma (objfile->obfd, sect);
+ addr = bfd_get_section_vma (abfd, sect);
return addr;
}
We will fill it in later if we find out how. */
if (type == NULL)
{
- type = alloc_type (current_objfile);
+ type = alloc_type (coffread_objfile);
*type_addr = type;
}
return type;
char *debugfile;
debugfile = find_separate_debug_file_by_debuglink (objfile);
+ make_cleanup (xfree, debugfile);
if (debugfile)
{
bfd *abfd = symfile_bfd_open (debugfile);
+ make_cleanup_bfd_unref (abfd);
symbol_file_add_separate (abfd, symfile_flags, objfile);
- xfree (debugfile);
}
}
if (val < 0)
perror_with_name (objfile->name);
- current_objfile = objfile;
+ coffread_objfile = objfile;
nlist_bfd_global = objfile->obfd;
nlist_nsyms_global = nsyms;
last_source_file = NULL;
ALL_OBJFILE_SYMTABS (objfile, s)
patch_opaque_types (s);
- current_objfile = NULL;
+ coffread_objfile = NULL;
}
\f
/* Routines for reading headers and symbols from executable. */
cs->c_symnum = symnum;
bytes = bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
if (bytes != local_symesz)
- error (_("%s: error reading symbols"), current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_objfile->name);
bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym);
cs->c_naux = sym->n_numaux & 0xff;
if (cs->c_naux >= 1)
{
bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
if (bytes != local_auxesz)
- error (_("%s: error reading symbols"), current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_objfile->name);
bfd_coff_swap_aux_in (symfile_bfd, temp_aux,
sym->n_type, sym->n_sclass,
0, cs->c_naux, (char *) aux);
{
bytes = bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
if (bytes != local_auxesz)
- error (_("%s: error reading symbols"), current_objfile->name);
+ error (_("%s: error reading symbols"), coffread_objfile->name);
}
}
cs->c_name = getsymname (sym);
coff_getfilename (union internal_auxent *aux_entry)
{
static char buffer[BUFSIZ];
- char *temp;
const char *result;
if (aux_entry->x_file.x_n.x_zeroes == 0)
if (TYPE_NAME (real_target))
{
+ /* The previous copy of TYPE_NAME is allocated by
+ process_coff_symbol. */
if (TYPE_NAME (target))
- xfree (TYPE_NAME (target));
- TYPE_NAME (target) = concat (TYPE_NAME (real_target),
- (char *) NULL);
+ xfree ((char*) TYPE_NAME (target));
+ TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target));
}
}
patch_opaque_types (struct symtab *s)
{
struct block *b;
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *real_sym;
/* Go through the per-file symbols only. */
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
- char *name = SYMBOL_LINKAGE_NAME (real_sym);
+ const char *name = SYMBOL_LINKAGE_NAME (real_sym);
int hash = hashname (name);
struct symbol *sym, *prev;
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
- concat (SYMBOL_LINKAGE_NAME (sym), (char *) NULL);
+ xstrdup (SYMBOL_LINKAGE_NAME (sym));
}
/* Keep track of any type which points to empty structured
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = SYMBOL_LINKAGE_NAME (xsym);
- SET_FIELD_BITPOS (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
+ SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
default_symfile_relocate, /* sym_relocate: Relocate a debug
section. */
+ NULL, /* sym_probe_fns */
&psym_functions
};