diff options
author | Fred Fish <fnf@specifix.com> | 1991-12-16 20:57:28 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1991-12-16 20:57:28 +0000 |
commit | f8b76e70b7a1cb376bc4ac8ac071fff5c7cf6acd (patch) | |
tree | bfb5400a70021ef29b9b687b2b44bb926ed51c47 /gdb/elfread.c | |
parent | 01d4cbef85c08a2f983cd4f83f4bbadc9f4ed320 (diff) | |
download | gdb-f8b76e70b7a1cb376bc4ac8ac071fff5c7cf6acd.zip gdb-f8b76e70b7a1cb376bc4ac8ac071fff5c7cf6acd.tar.gz gdb-f8b76e70b7a1cb376bc4ac8ac071fff5c7cf6acd.tar.bz2 |
Numerous small changes and a complete reorganization of solib.c, to support
SVR4 shared libraries in a manner very close to the original SunOS support.
See the ChangeLog for details.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r-- | gdb/elfread.c | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c index 5de3cd7..c7783e1 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -93,6 +93,32 @@ DEFUN(elf_locate_sections, (abfd, sectp, ei), } } +char * +DEFUN(elf_interpreter, (abfd), + bfd *abfd) +{ + sec_ptr interp_sec; + unsigned size; + char *interp = NULL; + + interp_sec = bfd_get_section_by_name (abfd, ".interp"); + if (interp_sec) + { + size = bfd_section_size (abfd, interp_sec); + interp = alloca (size); + if (bfd_get_section_contents (abfd, interp_sec, interp, (file_ptr)0, + size)) + { + interp = savestring (interp, size - 1); + } + else + { + interp = NULL; + } + } + return (interp); +} + /* LOCAL FUNCTION @@ -117,16 +143,37 @@ NOTES */ static void -DEFUN(record_misc_function, (name, address), char *name AND CORE_ADDR address) +DEFUN(record_misc_function, (name, address, mf_type), + char *name AND CORE_ADDR address AND enum misc_function_type mf_type) { prim_record_misc_function (obsavestring (name, strlen (name)), address, - mf_unknown); + mf_type); } +/* + +LOCAL FUNCTION + + elf_symtab_read -- read the symbol table of an ELF file + +SYNOPSIS + + void elf_symtab_read (bfd *abfd, CORE_ADDR addr, int mainline) + +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. + +*/ + static void -DEFUN (elf_symtab_read, (abfd, addr), +DEFUN (elf_symtab_read, (abfd, addr, mainline), bfd *abfd AND - CORE_ADDR addr) + CORE_ADDR addr AND + int mainline) { unsigned int storage_needed; asymbol *sym; @@ -134,6 +181,8 @@ DEFUN (elf_symtab_read, (abfd, addr), unsigned int number_of_symbols; unsigned int i; struct cleanup *back_to; + CORE_ADDR symaddr; + enum misc_function_type mf_type; storage_needed = get_symtab_upper_bound (abfd); @@ -151,7 +200,28 @@ DEFUN (elf_symtab_read, (abfd, addr), if (sym -> flags & BSF_GLOBAL && ((sym -> section != NULL) || (sym -> flags & BSF_ABSOLUTE))) { - record_misc_function ((char *) sym -> name, sym -> value); + symaddr = sym -> value; + if (!mainline) + { + /* Relocate all symbols by base address */ + symaddr += addr; + } + /* For non-absolute symbols, use the type of the section + they are relative to, to intuit text/data. Bfd provides + no way of figuring this out for absolute symbols. */ + if (sym -> section && (sym -> section -> flags & SEC_CODE)) + { + mf_type = mf_text; + } + else if (sym -> section && (sym -> section -> flags & SEC_DATA)) + { + mf_type = mf_data; + } + else + { + mf_type = mf_unknown; + } + record_misc_function ((char *) sym -> name, symaddr, mf_type); } } do_cleanups (back_to); @@ -199,7 +269,7 @@ DEFUN(elf_symfile_read, (sf, addr, mainline), /* Process the normal ELF symbol table first. */ - elf_symtab_read (abfd, addr); + elf_symtab_read (abfd, addr, mainline); /* Now process the DWARF debugging information, which is contained in special ELF sections. We first have to find them... */ @@ -208,7 +278,6 @@ DEFUN(elf_symfile_read, (sf, addr, mainline), bfd_map_over_sections (abfd, elf_locate_sections, &ei); if (ei.dboffset && ei.lnoffset) { - addr = 0; /* FIXME: force address base to zero for now */ dwarf_build_psymtabs (fileno ((FILE *)(abfd -> iostream)), bfd_get_filename (abfd), addr, mainline, |