I noticed that elfread.c always allocates a dbx_symfile_info, even
though this is only ever needed in the unusual case of reading stabs
in ELF.
This patch moves the allocation into dbxread.c, and applies the same
treatment to similar code in coffread.c.
Regression tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-06-10 Tom Tromey <tromey@adacore.com>
* elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile
data.
(elf_new_init): Don't call stabsread_new_init.
* dbxread.c (coffstab_build_psymtabs): Set dbx objfile data.
(elfstab_build_psymtabs): Likewise. Call stabsread_new_init.
* coffread.c (coff_symfile_init): Don't set the dbx objfile data.
+2019-06-10 Tom Tromey <tromey@adacore.com>
+
+ * elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile
+ data.
+ (elf_new_init): Don't call stabsread_new_init.
+ * dbxread.c (coffstab_build_psymtabs): Set dbx objfile data.
+ (elfstab_build_psymtabs): Likewise. Call stabsread_new_init.
+ * coffread.c (coff_symfile_init): Don't set the dbx objfile data.
+
2019-06-10 Tom de Vries <tdevries@suse.de>
PR symtab/16264
2019-06-10 Tom de Vries <tdevries@suse.de>
PR symtab/16264
#include "libcoff.h" /* FIXME secret internal data from BFD */
#include "objfiles.h"
#include "buildsym-legacy.h"
#include "libcoff.h" /* FIXME secret internal data from BFD */
#include "objfiles.h"
#include "buildsym-legacy.h"
#include "stabsread.h"
#include "complaints.h"
#include "target.h"
#include "stabsread.h"
#include "complaints.h"
#include "target.h"
static void
coff_symfile_init (struct objfile *objfile)
{
static void
coff_symfile_init (struct objfile *objfile)
{
- struct dbx_symfile_info *dbx;
-
- /* 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. */
coff_objfile_data_key.emplace (objfile);
/* Allocate struct to keep track of the symfile. */
coff_objfile_data_key.emplace (objfile);
char *name = bfd_get_filename (sym_bfd);
unsigned int stabsize;
char *name = bfd_get_filename (sym_bfd);
unsigned int stabsize;
+ /* Allocate struct to keep track of stab reading. */
+ struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
+
DBX_TEXT_ADDR (objfile) = textaddr;
DBX_TEXT_SIZE (objfile) = textsize;
DBX_TEXT_ADDR (objfile) = textaddr;
DBX_TEXT_SIZE (objfile) = textsize;
bfd *sym_bfd = objfile->obfd;
char *name = bfd_get_filename (sym_bfd);
bfd *sym_bfd = objfile->obfd;
char *name = bfd_get_filename (sym_bfd);
+ stabsread_new_init ();
+
+ /* Allocate struct to keep track of stab reading. */
+ struct dbx_symfile_info *dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
+
/* Find the first and last text address. dbx_symfile_read seems to
want this. */
find_text_range (sym_bfd, objfile);
/* Find the first and last text address. dbx_symfile_read seems to
want this. */
find_text_range (sym_bfd, objfile);
#include "symfile.h"
#include "objfiles.h"
#include "stabsread.h"
#include "symfile.h"
#include "objfiles.h"
#include "stabsread.h"
#include "complaints.h"
#include "demangle.h"
#include "psympriv.h"
#include "complaints.h"
#include "demangle.h"
#include "psympriv.h"
long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms;
long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms;
- struct dbx_symfile_info *dbx;
if (symtab_create_debug)
{
if (symtab_create_debug)
{
minimal_symbol_reader reader (objfile);
minimal_symbol_reader reader (objfile);
- /* Allocate struct to keep track of the symfile. */
- dbx = XCNEW (struct dbx_symfile_info);
- set_objfile_data (objfile, dbx_objfile_data_key, dbx);
-
/* Process the normal ELF symbol table first. */
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
/* Process the normal ELF symbol table first. */
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
/* Initialize anything that needs initializing when a completely new symbol
file is specified (not just adding some symbols from another file, e.g. a
/* Initialize anything that needs initializing when a completely new symbol
file is specified (not just adding some symbols from another file, e.g. a
- shared library).
-
- We reinitialize buildsym, since we may be reading stabs from an ELF
- file. */
static void
elf_new_init (struct objfile *ignore)
{
static void
elf_new_init (struct objfile *ignore)
{
}
/* Perform any local cleanups required when we are done with a particular
}
/* Perform any local cleanups required when we are done with a particular