kevinb / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
5a6df07
http://sourceware.org/ml/gdb-patches/2010-02/msg00477.html
5a6df07
Subject: Re: [patch] Fix crash on stale addrinfo->sectindex
5a6df07
5a6df07
On Fri, 19 Feb 2010 04:01:05 +0100, Tom Tromey wrote:
5a6df07
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
5a6df07
> I think you ought to move this comment as well.
5a6df07
> It appears to just be hanging at the end of a block after the patch.
5a6df07
5a6df07
Yes; forgot.
5a6df07
5a6df07
> This is ok with that change.  Thanks.
5a6df07
5a6df07
Checked-in.
5a6df07
5a6df07
On Fri, 19 Feb 2010 04:10:30 +0100, Tom Tromey wrote:
5a6df07
> Oh, by the way, I think this is reasonable for 7.1.  It is
5a6df07
> straightforward and fixes a reported crash.  If Joel agrees, please put
5a6df07
> it on the branch.  Thanks.
5a6df07
5a6df07
OK for the branch?
5a6df07
5a6df07
5a6df07
Thanks,
5a6df07
Jan
5a6df07
5a6df07
5a6df07
http://sourceware.org/ml/gdb-cvs/2010-02/msg00162.html
5a6df07
5a6df07
### src/gdb/ChangeLog	2010/02/19 00:35:53	1.11380
5a6df07
### src/gdb/ChangeLog	2010/02/19 06:19:44	1.11381
5a6df07
## -1,3 +1,10 @@
5a6df07
+2010-02-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
5a6df07
+
5a6df07
+	* symfile.c (addr_info_make_relative): Extend comment.  Move SECT to
5a6df07
+	a more inner block.  Initialize ADDR by LOWER_OFFSET only if it was
5a6df07
+	found by bfd_get_section_by_name.
5a6df07
+	* symfile.h (struct section_addr_info) <sectindex>: New comment.
5a6df07
+
5a6df07
 2010-02-19  Joel Brobecker  <brobecker@adacore.com>
5a6df07
 
5a6df07
 	* NEWS: Add new "[...] since 7.1" section.  Rename the "[...] since
5a6df07
--- src/gdb/symfile.c	2010/02/18 19:17:00	1.272
5a6df07
+++ src/gdb/symfile.c	2010/02/19 06:19:45	1.273
5a6df07
@@ -562,13 +562,13 @@
5a6df07
 }
5a6df07
 
5a6df07
 /* Relativize absolute addresses in ADDRS into offsets based on ABFD.  Fill-in
5a6df07
-   also SECTINDEXes there.  */
5a6df07
+   also SECTINDEXes specific to ABFD there.  This function can be used to
5a6df07
+   rebase ADDRS to start referencing different BFD than before.  */
5a6df07
 
5a6df07
 void
5a6df07
 addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
5a6df07
 {
5a6df07
   asection *lower_sect;
5a6df07
-  asection *sect;
5a6df07
   CORE_ADDR lower_offset;
5a6df07
   int i;
5a6df07
 
5a6df07
@@ -597,25 +597,29 @@
5a6df07
 
5a6df07
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
5a6df07
     {
5a6df07
-      if (addrs->other[i].addr != 0)
5a6df07
+      asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
5a6df07
+
5a6df07
+      if (sect)
5a6df07
 	{
5a6df07
-	  sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
5a6df07
-	  if (sect)
5a6df07
+	  /* This is the index used by BFD. */
5a6df07
+	  addrs->other[i].sectindex = sect->index;
5a6df07
+
5a6df07
+	  if (addrs->other[i].addr != 0)
5a6df07
 	    {
5a6df07
 	      addrs->other[i].addr -= bfd_section_vma (abfd, sect);
5a6df07
 	      lower_offset = addrs->other[i].addr;
5a6df07
-	      /* This is the index used by BFD. */
5a6df07
-	      addrs->other[i].sectindex = sect->index;
5a6df07
 	    }
5a6df07
 	  else
5a6df07
-	    {
5a6df07
-	      warning (_("section %s not found in %s"), addrs->other[i].name,
5a6df07
-		       bfd_get_filename (abfd));
5a6df07
-	      addrs->other[i].addr = 0;
5a6df07
-	    }
5a6df07
+	    addrs->other[i].addr = lower_offset;
5a6df07
 	}
5a6df07
       else
5a6df07
-	addrs->other[i].addr = lower_offset;
5a6df07
+	{
5a6df07
+	  warning (_("section %s not found in %s"), addrs->other[i].name,
5a6df07
+		   bfd_get_filename (abfd));
5a6df07
+	  addrs->other[i].addr = 0;
5a6df07
+
5a6df07
+	  /* SECTINDEX is invalid if ADDR is zero.  */
5a6df07
+	}
5a6df07
     }
5a6df07
 }
5a6df07
 
5a6df07
--- src/gdb/symfile.h	2010/02/03 14:13:16	1.64
5a6df07
+++ src/gdb/symfile.h	2010/02/19 06:19:45	1.65
5a6df07
@@ -80,6 +80,8 @@
5a6df07
   {
5a6df07
     CORE_ADDR addr;
5a6df07
     char *name;
5a6df07
+
5a6df07
+    /* SECTINDEX must be valid for associated BFD if ADDR is not zero.  */
5a6df07
     int sectindex;
5a6df07
   } other[1];
5a6df07
 };
5a6df07