#include "aout/stab_gnu.h"
\f
-/* Key for XCOFF-associated data. */
-
-static const struct objfile_data *xcoff_objfile_data_key;
-
/* We put a pointer to this structure in the read_symtab_private field
of the psymtab. */
static unsigned local_symesz;
-struct coff_symfile_info
+struct xcoff_symfile_info
{
- file_ptr min_lineno_offset; /* Where in file lowest line#s are. */
- file_ptr max_lineno_offset; /* 1+last byte of line#s in file. */
+ file_ptr min_lineno_offset {}; /* Where in file lowest line#s are. */
+ file_ptr max_lineno_offset {}; /* 1+last byte of line#s in file. */
/* Pointer to the string table. */
- char *strtbl;
+ char *strtbl = nullptr;
/* Pointer to debug section. */
- char *debugsec;
+ char *debugsec = nullptr;
/* Pointer to the a.out symbol table. */
- char *symtbl;
+ char *symtbl = nullptr;
/* Number of symbols in symtbl. */
- int symtbl_num_syms;
+ int symtbl_num_syms = 0;
/* Offset in data section to TOC anchor. */
- CORE_ADDR toc_offset;
+ CORE_ADDR toc_offset = 0;
};
+/* Key for XCOFF-associated data. */
+
+static const struct objfile_key<xcoff_symfile_info> xcoff_objfile_data_key;
+
/* Convenience macro to access the per-objfile XCOFF data. */
#define XCOFF_DATA(objfile) \
- ((struct coff_symfile_info *) objfile_data ((objfile), \
- xcoff_objfile_data_key))
+ xcoff_objfile_data_key.get (objfile)
/* XCOFF names for dwarf sections. There is no compressed sections. */
{
bfd *abfd = objfile->obfd;
char *raw_auxptr; /* Pointer to first raw aux entry for sym. */
- struct coff_symfile_info *xcoff = XCOFF_DATA (objfile);
+ struct xcoff_symfile_info *xcoff = XCOFF_DATA (objfile);
char *strtbl = xcoff->strtbl;
char *debugsec = xcoff->debugsec;
const char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
static void
read_symbol (struct internal_syment *symbol, int symno)
{
- struct coff_symfile_info *xcoff = XCOFF_DATA (this_symtab_objfile);
+ struct xcoff_symfile_info *xcoff = XCOFF_DATA (this_symtab_objfile);
int nsyms = xcoff->symtbl_num_syms;
char *stbl = xcoff->symtbl;
struct objfile *objfile = this_symtab_objfile;
int xcoff64 = bfd_xcoff_is_xcoff64 (objfile->obfd);
- struct coff_symfile_info *info = XCOFF_DATA (objfile);
+ struct xcoff_symfile_info *info = XCOFF_DATA (objfile);
int nsyms = info->symtbl_num_syms;
char *stbl = info->symtbl;
char *strtbl = info->strtbl;
static void
find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
{
- struct coff_symfile_info *info;
+ struct xcoff_symfile_info *info;
int size, count;
file_ptr offset, maxoff;
return;
size = count * coff_data (abfd)->local_linesz;
- info = (struct coff_symfile_info *) vpinfo;
+ info = (struct xcoff_symfile_info *) vpinfo;
offset = asect->line_filepos;
maxoff = offset + size;
static void
xcoff_symfile_init (struct objfile *objfile)
{
- struct coff_symfile_info *xcoff;
-
/* Allocate struct to keep track of the symfile. */
- xcoff = XNEW (struct coff_symfile_info);
- set_objfile_data (objfile, xcoff_objfile_data_key, xcoff);
+ xcoff_objfile_data_key.emplace (objfile);
/* XCOFF objects may be reordered, so set OBJF_REORDERED. If we
find this causes a significant slowdown in gdb then we could
int val;
unsigned char lengthbuf[4];
char *strtbl;
- struct coff_symfile_info *xcoff = XCOFF_DATA (objfile);
+ struct xcoff_symfile_info *xcoff = XCOFF_DATA (objfile);
xcoff->strtbl = NULL;
static struct partial_symtab *
xcoff_start_psymtab (struct objfile *objfile,
- const char *filename, int first_symnum,
- std::vector<partial_symbol *> &global_psymbols,
- std::vector<partial_symbol *> &static_psymbols)
+ const char *filename, int first_symnum)
{
struct partial_symtab *result =
start_psymtab_common (objfile,
filename,
/* We fill in textlow later. */
- 0,
- global_psymbols, static_psymbols);
+ 0);
result->read_symtab_private =
XOBNEW (&objfile->objfile_obstack, struct symloc);
pst->number_of_dependencies = number_dependencies;
if (number_dependencies)
{
- pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
- struct partial_symtab *,
- number_dependencies);
+ pst->dependencies
+ = objfile->partial_symtabs->allocate_dependencies (number_dependencies);
memcpy (pst->dependencies, dependency_list,
number_dependencies * sizeof (struct partial_symtab *));
}
/* We could save slight bits of space by only making one of these,
shared by the entire set of include files. FIXME-someday. */
subpst->dependencies =
- XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
+ objfile->partial_symtabs->allocate_dependencies (1);
subpst->dependencies[0] = pst;
subpst->number_of_dependencies = 1;
pst = xcoff_start_psymtab
(objfile,
filestring,
- symnum_before,
- objfile->global_psymbols,
- objfile->static_psymbols);
+ symnum_before);
}
}
/* Activate the misc_func_recorded mechanism for
pst = xcoff_start_psymtab (objfile,
filestring,
- symnum_before,
- objfile->global_psymbols,
- objfile->static_psymbols);
+ symnum_before);
last_csect_name = NULL;
}
break;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
symbol.n_value,
psymtab_language, objfile);
continue;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
SECT_OFF_DATA (objfile),
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
symbol.n_value,
psymtab_language, objfile);
continue;
{
add_psymbol_to_list (namestring, p - namestring, 1,
STRUCT_DOMAIN, LOC_TYPEDEF, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
if (p[2] == 't')
{
/* Also a typedef with the same name. */
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
p += 1;
}
{
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
}
check_enum:
enum constants in psymtabs, just in symtabs. */
add_psymbol_to_list (p, q - p, 1,
VAR_DOMAIN, LOC_CONST, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
/* Point past the name. */
p = q;
/* Constant, e.g. from "const" in Pascal. */
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_CONST, -1,
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
0, psymtab_language, objfile);
continue;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
- &objfile->static_psymbols,
+ psymbol_placement::STATIC,
symbol.n_value,
psymtab_language, objfile);
continue;
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
SECT_OFF_TEXT (objfile),
- &objfile->global_psymbols,
+ psymbol_placement::GLOBAL,
symbol.n_value,
psymtab_language, objfile);
continue;
int num_symbols; /* # of symbols */
file_ptr symtab_offset; /* symbol table and */
file_ptr stringtab_offset; /* string table file offsets */
- struct coff_symfile_info *info;
+ struct xcoff_symfile_info *info;
const char *name;
unsigned int size;
if (val != size)
perror_with_name (_("reading symbol table"));
- /* If we are reinitializing, or if we have never loaded syms yet, init. */
- if (objfile->global_psymbols.capacity () == 0
- && objfile->static_psymbols.capacity () == 0)
- /* I'm not sure how how good num_symbols is; the rule of thumb in
- init_psymbol_list was developed for a.out. On the one hand,
- num_symbols includes auxents. On the other hand, it doesn't
- include N_SLINE. */
- init_psymbol_list (objfile, num_symbols);
+ /* I'm not sure how how good num_symbols is; the rule of thumb in
+ init_psymbol_list was developed for a.out. On the one hand,
+ num_symbols includes auxents. On the other hand, it doesn't
+ include N_SLINE. */
+ init_psymbol_list (objfile, num_symbols);
scoped_free_pendings free_pending;
minimal_symbol_reader reader (objfile);
return l_nimpid - 1;
}
-/* Free the per-objfile xcoff data. */
-
-static void
-xcoff_free_info (struct objfile *objfile, void *arg)
-{
- xfree (arg);
-}
-
void
_initialize_xcoffread (void)
{
add_symtab_fns (bfd_target_xcoff_flavour, &xcoff_sym_fns);
-
- xcoff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
- xcoff_free_info);
}