aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2007-10-31 19:09:14 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2007-10-31 19:09:14 +0000
commit02c75f7232cf582a5ec8ec752e14b10cf72f6d1a (patch)
tree7008b4b41fbbbcf65a7449937950be86d050b238 /gdb/elfread.c
parent8f3bca322366c93d642c4fca6e880660c3dc029f (diff)
downloadgdb-02c75f7232cf582a5ec8ec752e14b10cf72f6d1a.zip
gdb-02c75f7232cf582a5ec8ec752e14b10cf72f6d1a.tar.gz
gdb-02c75f7232cf582a5ec8ec752e14b10cf72f6d1a.tar.bz2
* elfread.c (elf_symtab_read): When constructing a solib trampoline
minimal symbol from an undefined dynamic symbol, use proper section.
Diffstat (limited to 'gdb/elfread.c')
-rw-r--r--gdb/elfread.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index e479a76..26ee99e 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -240,6 +240,8 @@ elf_symtab_read (struct objfile *objfile, int dynamic,
&& (sym->flags & BSF_FUNCTION))
{
struct minimal_symbol *msym;
+ bfd *abfd = objfile->obfd;
+ asection *sect;
/* Symbol is a reference to a function defined in
a shared library.
@@ -252,10 +254,28 @@ elf_symtab_read (struct objfile *objfile, int dynamic,
symaddr = sym->value;
if (symaddr == 0)
continue;
- symaddr += offset;
+
+ /* sym->section is the undefined section. However, we want to
+ record the section where the PLT stub resides with the
+ minimal symbol. Search the section table for the one that
+ covers the stub's address. */
+ for (sect = abfd->sections; sect != NULL; sect = sect->next)
+ {
+ if ((bfd_get_section_flags (abfd, sect) & SEC_ALLOC) == 0)
+ continue;
+
+ if (symaddr >= bfd_get_section_vma (abfd, sect)
+ && symaddr < bfd_get_section_vma (abfd, sect)
+ + bfd_get_section_size (sect))
+ break;
+ }
+ if (!sect)
+ continue;
+
+ symaddr += ANOFFSET (objfile->section_offsets, sect->index);
+
msym = record_minimal_symbol
- ((char *) sym->name, symaddr,
- mst_solib_trampoline, sym->section, objfile);
+ ((char *) sym->name, symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
msym->filename = filesymname;
continue;