"gdb vmlinux" gives wrong symbol addresses

Jan Kratochvil jan.kratochvil@redhat.com
Wed Aug 23 18:31:00 GMT 2006


On Mon, 21 Aug 2006 05:24:19 +0200, Alan Modra wrote:
> On Sun, Aug 20, 2006 at 09:54:30PM -0400, Daniel Jacobowitz wrote:
> > On Mon, Aug 21, 2006 at 11:08:29AM +0930, Alan Modra wrote:
> > > I think that for ET_EXEC and ET_DYN gdb should ignore relocs that use
> > > the normal symbol table.  Sane ELF targets will have dynamic reloc
> > > section(s) with sh_link pointing at a symtab section with sh_type of
> > > SHT_DYNSYM.  --emit-relocs creates reloc sections with sh_link pointing
> > > at a symtab section with sh_type of SHT_SYMTAB.
> > 
> > This amounts to always ignoring relocations; GDB only uses relocations
> > for debug sections, which will never point at SHT_DYNSYM (I don't
> > think?).
> 
> When we emitted relocs for debug sections on some targets (eg. ppc32
> prior to 2005-04-19), they were against SHT_DYNSYM symbols.

Do you have such (ppc32?) shared library(?) binary handy?
It would be find to include it to the gdb testsuite.

The restricted patch targetting relocatable Linux kernel but not targetting the
libraries attached, IMO safe.  It is gdb-only patch, not binutils-wide.


Regards,
Jan
-------------- next part --------------
--- sources-clean/gdb/symfile.c	2006-08-23 09:22:21.000000000 +0200
+++ sources-custom/gdb/symfile.c	2006-08-23 09:54:24.000000000 +0200
@@ -3713,6 +3713,12 @@
 bfd_byte *
 symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte *buf)
 {
+  /* Executable files have all the relocations already resolved.
+   * Handle files linked with --emit-relocs.
+   * http://sources.redhat.com/ml/gdb/2006-08/msg00137.html  */
+  if ((abfd->flags & EXEC_P) != 0)
+    return NULL;
+
   /* We're only interested in debugging sections with relocation
      information.  */
   if ((sectp->flags & SEC_RELOC) == 0)


More information about the Binutils mailing list