aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r--gdb/elfread.c136
1 files changed, 76 insertions, 60 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index a24f4c2..f1d7f49 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -29,10 +29,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
* FIXME Still needs support for shared libraries. *
* FIXME Still needs support for core files. *
* FIXME The ".debug" and ".line" section names are hardwired. *
- * FIXME Still needs support ELF symbol tables (as distinct *
- * from DWARF support). Can use them to build the misc *
- * function vector at least. This is fairly trivial once *
- * bfd is extended to handle ELF symbol tables. *
* *
************************************************************************/
@@ -43,15 +39,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "elf/external.h"
#include "elf/internal.h"
#include "bfd.h"
-#include "symfile.h"
#include "symtab.h"
-#include "ansidecl.h"
-
-extern int EXFUN (strcmp, (CONST char *a, CONST char *b));
-extern int EXFUN (dwarf_build_psymtabs,
- (int desc, char *filename, CORE_ADDR addr, int mainline,
- unsigned int dbfoff, unsigned int dbsize, unsigned int lnoffset,
- unsigned int lnsize, struct objfile *objfile));
+#include "symfile.h"
#define STREQ(a,b) (strcmp((a),(b))==0)
@@ -62,6 +51,25 @@ struct elfinfo {
unsigned int lnsize; /* Size of dwarf line number section */
};
+static void
+elf_symfile_init PARAMS ((struct sym_fns *));
+
+static void
+elf_new_init PARAMS ((void));
+
+static void
+elf_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
+
+static void
+elf_symtab_read PARAMS ((bfd *, CORE_ADDR, int, struct objfile *));
+
+static void
+record_minimal_symbol PARAMS ((char *, CORE_ADDR, enum minimal_symbol_type,
+ struct objfile *));
+
+static void
+elf_locate_sections PARAMS ((bfd *, asection *, PTR));
+
/* We are called once per section from elf_symfile_read. We
need to examine each section we are passed, check to see
if it is something we are interested in processing, and
@@ -76,11 +84,14 @@ struct elfinfo {
FIXME: The section names should not be hardwired strings. */
static void
-DEFUN(elf_locate_sections, (abfd, sectp, ei),
- bfd *abfd AND
- asection *sectp AND
- struct elfinfo *ei)
+elf_locate_sections (abfd, sectp, eip)
+ bfd *abfd;
+ asection *sectp;
+ PTR eip;
{
+ register struct elfinfo *ei;
+
+ ei = (struct elfinfo *) eip;
if (STREQ (sectp -> name, ".debug"))
{
ei -> dboffset = sectp -> filepos;
@@ -93,9 +104,11 @@ DEFUN(elf_locate_sections, (abfd, sectp, ei),
}
}
+#if 0 /* Currently unused */
+
char *
-DEFUN(elf_interpreter, (abfd),
- bfd *abfd)
+elf_interpreter (abfd)
+ bfd *abfd;
{
sec_ptr interp_sec;
unsigned size;
@@ -119,35 +132,35 @@ DEFUN(elf_interpreter, (abfd),
return (interp);
}
+#endif
+
/*
LOCAL FUNCTION
- record_misc_function -- add entry to miscellaneous function vector
+ record_minimal_symbol -- add entry to minimal symbol table
SYNOPSIS
- static void record_misc_function (char *name, CORE_ADDR address)
+ static void record_minimal_symbol (char *name, CORE_ADDR address)
DESCRIPTION
Given a pointer to the name of a symbol that should be added to the
- miscellaneous function vector, and the address associated with that
- symbol, records this information for later use in building the
- miscellaneous function vector.
-
-NOTES
+ minimal symbol table and the address associated with that symbol, records
+ this information for later use in building the minimal symbol table.
- FIXME: For now we just use mf_unknown as the type. This should be
- fixed.
*/
static void
-DEFUN(record_misc_function, (name, address, mf_type),
- char *name AND CORE_ADDR address AND enum misc_function_type mf_type)
+record_minimal_symbol (name, address, ms_type, objfile)
+ char *name;
+ CORE_ADDR address;
+ enum minimal_symbol_type ms_type;
+ struct objfile *objfile;
{
- prim_record_misc_function (obsavestring (name, strlen (name)), address,
- mf_type);
+ name = obsavestring (name, strlen (name), &objfile -> symbol_obstack);
+ prim_record_minimal_symbol (name, address, ms_type);
}
/*
@@ -158,22 +171,24 @@ LOCAL FUNCTION
SYNOPSIS
- void elf_symtab_read (bfd *abfd, CORE_ADDR addr, int mainline)
+ void elf_symtab_read (bfd *abfd, CORE_ADDR addr, int mainline,
+ struct objfile *objfile)
DESCRIPTION
Given an open bfd, a base address to relocate symbols to, and a
flag that specifies whether or not this bfd is for an executable
or not (may be shared library for example), add all the global
- function and data symbols to the miscellaneous function vector.
+ function and data symbols to the minimal symbol table.
*/
static void
-DEFUN (elf_symtab_read, (abfd, addr, mainline),
- bfd *abfd AND
- CORE_ADDR addr AND
- int mainline)
+elf_symtab_read (abfd, addr, mainline, objfile)
+ bfd *abfd;
+ CORE_ADDR addr;
+ int mainline;
+ struct objfile *objfile;
{
unsigned int storage_needed;
asymbol *sym;
@@ -182,7 +197,7 @@ DEFUN (elf_symtab_read, (abfd, addr, mainline),
unsigned int i;
struct cleanup *back_to;
CORE_ADDR symaddr;
- enum misc_function_type mf_type;
+ enum minimal_symbol_type ms_type;
storage_needed = get_symtab_upper_bound (abfd);
@@ -214,17 +229,17 @@ DEFUN (elf_symtab_read, (abfd, addr, mainline),
no way of figuring this out for absolute symbols. */
if (sym -> section -> flags & SEC_CODE)
{
- mf_type = mf_text;
+ ms_type = mst_text;
}
else if (sym -> section -> flags & SEC_DATA)
{
- mf_type = mf_data;
+ ms_type = mst_data;
}
else
{
- mf_type = mf_unknown;
+ ms_type = mst_unknown;
}
- record_misc_function ((char *) sym -> name, symaddr, mf_type);
+ record_minimal_symbol ((char *) sym -> name, symaddr, ms_type, objfile);
}
}
do_cleanups (back_to);
@@ -253,32 +268,32 @@ DEFUN (elf_symtab_read, (abfd, addr, mainline),
Note that ELF files have a "minimal" symbol table, which looks a lot
like a COFF symbol table, but has only the minimal information necessary
for linking. We process this also, and just use the information to
- add to the misc function vector. This gives us some minimal debugging
+ add to gdb's minimal symbol table. This gives us some minimal debugging
capability even for files compiled without -g.
*/
static void
-DEFUN(elf_symfile_read, (sf, addr, mainline),
- struct sym_fns *sf AND
- CORE_ADDR addr AND
- int mainline)
+elf_symfile_read (sf, addr, mainline)
+ struct sym_fns *sf;
+ CORE_ADDR addr;
+ int mainline;
{
bfd *abfd = sf->objfile->obfd;
struct elfinfo ei;
struct cleanup *back_to;
- init_misc_bunches ();
- back_to = make_cleanup (discard_misc_bunches, 0);
+ init_minimal_symbol_collection ();
+ back_to = make_cleanup (discard_minimal_symbols, 0);
/* Process the normal ELF symbol table first. */
- elf_symtab_read (abfd, addr, mainline);
+ elf_symtab_read (abfd, addr, mainline, sf->objfile);
/* Now process the DWARF debugging information, which is contained in
special ELF sections. We first have to find them... */
(void) memset ((char *) &ei, 0, sizeof (ei));
- bfd_map_over_sections (abfd, elf_locate_sections, &ei);
+ bfd_map_over_sections (abfd, elf_locate_sections, (PTR) &ei);
if (ei.dboffset && ei.lnoffset)
{
dwarf_build_psymtabs (fileno ((FILE *)(abfd -> iostream)),
@@ -288,17 +303,18 @@ DEFUN(elf_symfile_read, (sf, addr, mainline),
ei.lnoffset, ei.lnsize, sf->objfile);
}
- if (!partial_symtab_list)
+ if (!have_partial_symbols ())
{
wrap_here ("");
printf_filtered ("(no debugging symbols found)...");
wrap_here ("");
}
- /* Go over the miscellaneous functions and install them in the
- miscellaneous function vector. */
-
- condense_misc_bunches (!mainline);
+ /* Install any minimal symbols that have been collected as the current
+ minimal symbols for this objfile. */
+
+ install_minimal_symbols (!mainline, sf -> objfile);
+
do_cleanups (back_to);
}
@@ -310,7 +326,7 @@ DEFUN(elf_symfile_read, (sf, addr, mainline),
just a stub. */
static void
-DEFUN_VOID (elf_new_init)
+elf_new_init ()
{
}
@@ -324,8 +340,8 @@ DEFUN_VOID (elf_new_init)
just a stub. */
static void
-DEFUN(elf_symfile_init, (sf),
- struct sym_fns *sf)
+elf_symfile_init (sf)
+ struct sym_fns *sf;
{
}
@@ -358,7 +374,7 @@ static struct sym_fns elf_sym_fns = {
};
void
-DEFUN_VOID (_initialize_elfread)
+_initialize_elfread ()
{
add_symtab_fns (&elf_sym_fns);
}