aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-22 14:25:08 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:33 -0600
commit8dddcb8f005e8470312bf33041bb6ddaa5084e32 (patch)
treed88f904c0193031ec5215f25f03201d321a558cc /gdb/elfread.c
parentd25e87199327846e42b5a23f4365d75e75517ab3 (diff)
downloadgdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.zip
gdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.tar.gz
gdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.tar.bz2
Record minimal symbols directly in reader.
This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r--gdb/elfread.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 58e0cbc..56fac28 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -191,7 +191,8 @@ elf_locate_sections (bfd *ignore_abfd, asection *sectp, void *eip)
}
static struct minimal_symbol *
-record_minimal_symbol (const char *name, int name_len, int copy_name,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, int name_len, int copy_name,
CORE_ADDR address,
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
@@ -202,11 +203,10 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
|| ms_type == mst_text_gnu_ifunc)
address = gdbarch_addr_bits_remove (gdbarch, address);
- return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
- ms_type,
- gdb_bfd_section_index (objfile->obfd,
- bfd_section),
- objfile);
+ return reader.record_full (name, name_len, copy_name, address,
+ ms_type,
+ gdb_bfd_section_index (objfile->obfd,
+ bfd_section));
}
/* Read the symbol table of an ELF file.
@@ -226,7 +226,8 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
#define ST_SYNTHETIC 2
static void
-elf_symtab_read (struct objfile *objfile, int type,
+elf_symtab_read (minimal_symbol_reader &reader,
+ struct objfile *objfile, int type,
long number_of_symbols, asymbol **symbol_table,
int copy_names)
{
@@ -318,7 +319,7 @@ elf_symtab_read (struct objfile *objfile, int type,
continue;
msym = record_minimal_symbol
- (sym->name, strlen (sym->name), copy_names,
+ (reader, sym->name, strlen (sym->name), copy_names,
symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
{
@@ -458,7 +459,7 @@ elf_symtab_read (struct objfile *objfile, int type,
continue; /* Skip this symbol. */
}
msym = record_minimal_symbol
- (sym->name, strlen (sym->name), copy_names, symaddr,
+ (reader, sym->name, strlen (sym->name), copy_names, symaddr,
ms_type, sym->section, objfile);
if (msym)
@@ -487,7 +488,7 @@ elf_symtab_read (struct objfile *objfile, int type,
{
int len = atsign - sym->name;
- record_minimal_symbol (sym->name, len, 1, symaddr,
+ record_minimal_symbol (reader, sym->name, len, 1, symaddr,
ms_type, sym->section, objfile);
}
}
@@ -504,7 +505,7 @@ elf_symtab_read (struct objfile *objfile, int type,
{
struct minimal_symbol *mtramp;
- mtramp = record_minimal_symbol (sym->name, len - 4, 1,
+ mtramp = record_minimal_symbol (reader, sym->name, len - 4, 1,
symaddr,
mst_solib_trampoline,
sym->section, objfile);
@@ -531,7 +532,8 @@ elf_symtab_read (struct objfile *objfile, int type,
DYN_SYMBOL_TABLE is no longer easily available for OBJFILE. */
static void
-elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
+elf_rel_plt_read (minimal_symbol_reader &reader,
+ struct objfile *objfile, asymbol **dyn_symbol_table)
{
bfd *obfd = objfile->obfd;
const struct elf_backend_data *bed = get_elf_backend_data (obfd);
@@ -608,7 +610,8 @@ elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
memcpy (&string_buffer[name_len], SYMBOL_GOT_PLT_SUFFIX,
got_suffix_len + 1);
- msym = record_minimal_symbol (string_buffer, name_len + got_suffix_len,
+ msym = record_minimal_symbol (reader, string_buffer,
+ name_len + got_suffix_len,
1, address, mst_slot_got_plt, got_plt,
objfile);
if (msym)
@@ -1077,7 +1080,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_REGULAR, symcount, symbol_table, 0);
+ elf_symtab_read (reader, objfile, ST_REGULAR, symcount, symbol_table, 0);
}
/* Add the dynamic symbols. */
@@ -1102,9 +1105,10 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0);
+ elf_symtab_read (reader, objfile, ST_DYNAMIC, dynsymcount,
+ dyn_symbol_table, 0);
- elf_rel_plt_read (objfile, dyn_symbol_table);
+ elf_rel_plt_read (reader, objfile, dyn_symbol_table);
}
/* Contrary to binutils --strip-debug/--only-keep-debug the strip command from
@@ -1139,7 +1143,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
for (i = 0; i < synthcount; i++)
synth_symbol_table[i] = synthsyms + i;
make_cleanup (xfree, synth_symbol_table);
- elf_symtab_read (objfile, ST_SYNTHETIC, synthcount,
+ elf_symtab_read (reader, objfile, ST_SYNTHETIC, synthcount,
synth_symbol_table, 1);
}