* elfread.c (elf_symtab_read): When constructing a solib trampoline
authorUlrich Weigand <uweigand@de.ibm.com>
Wed, 31 Oct 2007 19:09:14 +0000 (19:09 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Wed, 31 Oct 2007 19:09:14 +0000 (19:09 +0000)
minimal symbol from an undefined dynamic symbol, use proper section.

gdb/ChangeLog
gdb/elfread.c

index c32d77c65c2bdc39c56f85b13d4da8444a934814..d95746c3e03732cb25b004ae777a9cd2e33961f2 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-31  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * elfread.c (elf_symtab_read): When constructing a solib trampoline
+       minimal symbol from an undefined dynamic symbol, use proper section.
+
 2007-10-31  Markus Deuling  <deuling@de.ibm.com>
 
        * arm-linux-nat.c (fetch_register, fetch_regs): Use get_regcache_arch
index e479a7698a79738adef1b39b0c3d6e6791a11f2d..26ee99e4701849c6c2635927095600203385632b 100644 (file)
@@ -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;