/* Read coff symbol tables and convert to internal format, for GDB.
- Copyright (C) 1987-2022 Free Software Foundation, Inc.
+ Copyright (C) 1987-2023 Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
This file is part of GDB.
/* Key for COFF-associated data. */
-static const struct objfile_key<coff_symfile_info> coff_objfile_data_key;
+static const registry<objfile>::key<coff_symfile_info> coff_objfile_data_key;
/* Translate an external name string into a user-visible name. */
#define EXTERNAL_NAME(string, abfd) \
/* Return the section_offsets* that CS points to. */
static int cs_to_section (struct coff_symbol *, struct objfile *);
-struct find_targ_sec_arg
+struct coff_find_targ_sec_arg
{
int targ_index;
asection **resultp;
static void
find_targ_sec (bfd *abfd, asection *sect, void *obj)
{
- struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj;
+ struct coff_find_targ_sec_arg *args = (struct coff_find_targ_sec_arg *) obj;
if (sect->target_index == args->targ_index)
*args->resultp = sect;
cs_to_bfd_section (struct coff_symbol *cs, struct objfile *objfile)
{
asection *sect = NULL;
- struct find_targ_sec_arg args;
+ struct coff_find_targ_sec_arg args;
args.targ_index = cs->c_secnum;
args.resultp = §
- bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
+ bfd_map_over_sections (objfile->obfd.get (), find_targ_sec, &args);
return sect;
}
if (sect == NULL)
return SECT_OFF_TEXT (objfile);
- return gdb_bfd_section_index (objfile->obfd, sect);
+ return gdb_bfd_section_index (objfile->obfd.get (), sect);
}
/* Return the address of the section of a COFF symbol. */
cs_section_address (struct coff_symbol *cs, bfd *abfd)
{
asection *sect = NULL;
- struct find_targ_sec_arg args;
+ struct coff_find_targ_sec_arg args;
CORE_ADDR addr = 0;
args.targ_index = cs->c_secnum;
name1 = name + 6;
if (name1 != NULL)
{
- int lead = bfd_get_symbol_leading_char (objfile->obfd);
+ int lead
+ = bfd_get_symbol_leading_char (objfile->obfd.get ());
struct bound_minimal_symbol found;
if (lead != '\0' && *name1 == lead)
coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct coff_symfile_info *info;
- bfd *abfd = objfile->obfd;
+ bfd *abfd = objfile->obfd.get ();
coff_data_type *cdata = coff_data (abfd);
const char *filename = bfd_get_filename (abfd);
int val;
FIXME: We should use BFD to read the symbol table, and thus avoid
this problem. */
pe_file =
- startswith (bfd_get_target (objfile->obfd), "pe")
- || startswith (bfd_get_target (objfile->obfd), "epoc-pe");
+ startswith (bfd_get_target (objfile->obfd.get ()), "pe")
+ || startswith (bfd_get_target (objfile->obfd.get ()), "epoc-pe");
/* End of warning. */
{
gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
- symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
+ symbol_file_add_separate (debug_bfd, debugfile.c_str (),
symfile_flags, objfile);
}
}
FIXME: Find out if this has been reported to Sun, whether it has
been fixed in a later release, etc. */
- bfd_seek (objfile->obfd, 0, 0);
+ bfd_seek (objfile->obfd.get (), 0, 0);
/* Position to read the symbol table. */
- val = bfd_seek (objfile->obfd, symtab_offset, 0);
+ val = bfd_seek (objfile->obfd.get (), symtab_offset, 0);
if (val < 0)
perror_with_name (objfile_name (objfile));
coffread_objfile = objfile;
- nlist_bfd_global = objfile->obfd;
+ nlist_bfd_global = objfile->obfd.get ();
nlist_nsyms_global = nsyms;
set_last_source_file (NULL);
memset (opaque_type_chain, 0, sizeof opaque_type_chain);
if (aux_entry->x_file.x_n.x_n.x_zeroes == 0)
{
if (strlen (stringtab + aux_entry->x_file.x_n.x_n.x_offset) >= BUFSIZ)
- internal_error (__FILE__, __LINE__, _("coff file name too long"));
+ internal_error (_("coff file name too long"));
strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_n.x_offset);
}
else
static void
patch_type (struct type *type, struct type *real_type)
{
- struct type *target = TYPE_TARGET_TYPE (type);
- struct type *real_target = TYPE_TARGET_TYPE (real_type);
+ struct type *target = type->target_type ();
+ struct type *real_target = real_type->target_type ();
int field_size = real_target->num_fields () * sizeof (struct field);
- TYPE_LENGTH (target) = TYPE_LENGTH (real_target);
+ target->set_length (real_target->length ());
target->set_num_fields (real_target->num_fields ());
field *fields = (struct field *) TYPE_ALLOC (target, field_size);
if (real_sym->aclass () == LOC_TYPEDEF
&& real_sym->domain () == VAR_DOMAIN
&& real_sym->type ()->code () == TYPE_CODE_PTR
- && TYPE_LENGTH (TYPE_TARGET_TYPE (real_sym->type ())) != 0)
+ && real_sym->type ()->target_type ()->length () != 0)
{
const char *name = real_sym->linkage_name ();
int hash = hashname (name);
char *name;
name = cs->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
sym->set_language (get_current_subfile ()->language,
&objfile->objfile_obstack);
sym->compute_and_set_names (name, true, objfile->per_bfd);
references work themselves out via the magic of
coff_lookup_type. */
if (sym->type ()->code () == TYPE_CODE_PTR
- && TYPE_LENGTH (TYPE_TARGET_TYPE (sym->type ())) == 0
- && TYPE_TARGET_TYPE (sym->type ())->code ()
+ && sym->type ()->target_type ()->length () == 0
+ && sym->type ()->target_type ()->code ()
!= TYPE_CODE_UNDEF)
{
int i = hashname (sym->linkage_name ());
type->set_code (TYPE_CODE_STRUCT);
type->set_name (NULL);
INIT_CPLUS_SPECIFIC (type);
- TYPE_LENGTH (type) = 0;
+ type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
type = coff_alloc_type (cs->c_symnum);
type->set_name (NULL);
INIT_CPLUS_SPECIFIC (type);
- TYPE_LENGTH (type) = 0;
+ type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
type = coff_alloc_type (cs->c_symnum);
type->set_code (TYPE_CODE_ENUM);
type->set_name (NULL);
- TYPE_LENGTH (type) = 0;
+ type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
type = coff_alloc_type (index);
type->set_code (TYPE_CODE_STRUCT);
INIT_CPLUS_SPECIFIC (type);
- TYPE_LENGTH (type) = length;
+ type->set_length (length);
while (!done && symnum < lastsym && symnum < nlist_nsyms_global)
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
switch (ms->c_sclass)
{
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd.get ());
switch (ms->c_sclass)
{
/* Now fill in the fields of the type-structure. */
if (length > 0)
- TYPE_LENGTH (type) = length;
+ type->set_length (length);
else /* Assume ints. */
- TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
+ type->set_length (gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT);
type->set_code (TYPE_CODE_ENUM);
type->set_num_fields (nsyms);
type->set_fields