/* Read ELF (Executable and Linking Format) object files for GDB.
- Copyright (C) 1991-2014 Free Software Foundation, Inc.
+ Copyright (C) 1991-2015 Free Software Foundation, Inc.
Written by Fred Fish at Cygnus Support.
#include "defs.h"
#include "bfd.h"
-#include <string.h>
#include "elf-bfd.h"
#include "elf/common.h"
#include "elf/internal.h"
extern void _initialize_elfread (void);
/* Forward declarations. */
-static const struct sym_fns elf_sym_fns_gdb_index;
-static const struct sym_fns elf_sym_fns_lazy_psyms;
+extern const struct sym_fns elf_sym_fns_gdb_index;
+extern const struct sym_fns elf_sym_fns_lazy_psyms;
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
asection *mdebugsect; /* Section pointer for .mdebug section */
};
-/* Per-objfile data for probe info. */
+/* Per-BFD data for probe info. */
-static const struct objfile_data *probe_key = NULL;
+static const struct bfd_data *probe_key = NULL;
static void free_elfinfo (void *);
const char *filesymname = "";
struct dbx_symfile_info *dbx = DBX_SYMFILE_INFO (objfile);
int stripped = (bfd_get_symcount (objfile->obfd) == 0);
+ int elf_make_msymbol_special_p
+ = gdbarch_elf_make_msymbol_special_p (gdbarch);
for (i = 0; i < number_of_symbols; i++)
{
(sym->name, strlen (sym->name), copy_names,
symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
- msym->filename = filesymname;
+ {
+ msym->filename = filesymname;
+ if (elf_make_msymbol_special_p)
+ gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
+ }
continue;
}
}
msym->filename = filesymname;
- gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
+ if (elf_make_msymbol_special_p)
+ gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
}
/* If we see a default versioned symbol, install it under
SET_MSYMBOL_SIZE (mtramp, MSYMBOL_SIZE (msym));
mtramp->created_by_gdb = 1;
mtramp->filename = filesymname;
- gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp);
+ if (elf_make_msymbol_special_p)
+ gdbarch_elf_make_msymbol_special (gdbarch,
+ sym, mtramp);
}
}
}
if (storage_needed > 0)
{
- symbol_table = (asymbol **) xmalloc (storage_needed);
- make_cleanup (xfree, symbol_table);
+ /* Memory gets permanently referenced from ABFD after
+ bfd_canonicalize_symtab so it must not get freed before ABFD gets. */
+
+ symbol_table = bfd_alloc (abfd, storage_needed);
symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
if (symcount < 0)
We have been initialized by a call to elf_symfile_init, which
currently does nothing.
- SECTION_OFFSETS is a set of offsets to apply to relocate the symbols
- in each section. We simplify it down to a single offset for all
- symbols. FIXME.
-
This function only does the minimum work necessary for letting the
user "name" things symbolically; it does not read the entire symtab.
Instead, it reads the external and static symbols and puts them in partial
dwarf2_free_objfile (objfile);
}
-/* ELF specific initialization routine for reading symbols.
-
- It is passed a pointer to a struct sym_fns which contains, among other
- things, the BFD for the file whose symbols are being read, and a slot for
- a pointer to "private data" which we can fill with goodies.
-
- For now at least, we have nothing in particular to do, so this function is
- just a stub. */
+/* ELF specific initialization routine for reading symbols. */
static void
elf_symfile_init (struct objfile *objfile)
static VEC (probe_p) *
elf_get_probes (struct objfile *objfile)
{
- VEC (probe_p) *probes_per_objfile;
+ VEC (probe_p) *probes_per_bfd;
/* Have we parsed this objfile's probes already? */
- probes_per_objfile = objfile_data (objfile, probe_key);
+ probes_per_bfd = bfd_data (objfile->obfd, probe_key);
- if (!probes_per_objfile)
+ if (!probes_per_bfd)
{
int ix;
const struct probe_ops *probe_ops;
objfile. */
for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops);
ix++)
- probe_ops->get_probes (&probes_per_objfile, objfile);
+ probe_ops->get_probes (&probes_per_bfd, objfile);
- if (probes_per_objfile == NULL)
+ if (probes_per_bfd == NULL)
{
- VEC_reserve (probe_p, probes_per_objfile, 1);
- gdb_assert (probes_per_objfile != NULL);
+ VEC_reserve (probe_p, probes_per_bfd, 1);
+ gdb_assert (probes_per_bfd != NULL);
}
- set_objfile_data (objfile, probe_key, probes_per_objfile);
+ set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
}
- return probes_per_objfile;
-}
-
-/* Implementation of `sym_relocate_probe', as documented in symfile.h. */
-
-static void
-elf_symfile_relocate_probe (struct objfile *objfile,
- const struct section_offsets *new_offsets,
- const struct section_offsets *delta)
-{
- int ix;
- VEC (probe_p) *probes = objfile_data (objfile, probe_key);
- struct probe *probe;
-
- for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
- probe->pops->relocate (probe, ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
+ return probes_per_bfd;
}
/* Helper function used to free the space allocated for storing SystemTap
probe information. */
static void
-probe_key_free (struct objfile *objfile, void *d)
+probe_key_free (bfd *abfd, void *d)
{
int ix;
VEC (probe_p) *probes = d;
static const struct sym_probe_fns elf_probe_fns =
{
elf_get_probes, /* sym_get_probes */
- elf_symfile_relocate_probe, /* sym_relocate_probe */
};
/* Register that we are able to handle ELF object file formats. */
/* The same as elf_sym_fns, but not registered and lazily reads
psymbols. */
-static const struct sym_fns elf_sym_fns_lazy_psyms =
+const struct sym_fns elf_sym_fns_lazy_psyms =
{
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
/* The same as elf_sym_fns, but not registered and uses the
DWARF-specific GNU index rather than psymtab. */
-static const struct sym_fns elf_sym_fns_gdb_index =
+const struct sym_fns elf_sym_fns_gdb_index =
{
elf_new_init, /* init anything gbl to entire symab */
elf_symfile_init, /* read initial info, setup for sym_red() */
void
_initialize_elfread (void)
{
- probe_key = register_objfile_data_with_cleanup (NULL, probe_key_free);
+ probe_key = register_bfd_data_with_cleanup (NULL, probe_key_free);
add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();