blarsen / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
d60484c
Fix i386-on-x86_64 debugging giving the warning:
d60484c
	warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4
d60484c
d60484c
[ Backport for RH GDB-6.6. ]
d60484c
d60484c
--- gdb-6.6/gdb/symfile.c	2007-10-08 19:52:06.000000000 +0200
d60484c
+++ gdb-6.6/gdb/symfile.c	2007-10-08 19:49:27.000000000 +0200
d60484c
@@ -597,6 +597,37 @@ default_symfile_offsets (struct objfile 
d60484c
   init_objfile_sect_indices (objfile);
d60484c
 }
d60484c
 
d60484c
+/* Find lowest loadable section to be used as starting point for continguous
d60484c
+   sections. FIXME!! won't work without call to find .text first, but this
d60484c
+   assumes text is lowest section.  vDSO was seen for i386-on-amd64 processes
d60484c
+   to have no `.text' as it has `.text.vsyscall', `.text.sigreturn' etc.
d60484c
+   instead.  Execution of this function has been delayed till it is really
d60484c
+   needed as it is broken for vDSOs, fortunately it is never needed on
d60484c
+   GNU/Linux.  */
d60484c
+
d60484c
+static CORE_ADDR
d60484c
+find_lower_offset (struct objfile *objfile)
d60484c
+{
d60484c
+  asection *lower_sect;
d60484c
+
d60484c
+  lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
d60484c
+  if (lower_sect == NULL)
d60484c
+    bfd_map_over_sections (objfile->obfd, find_lowest_section,
d60484c
+			   &lower_sect);
d60484c
+  if (lower_sect == NULL)
d60484c
+    warning (_("no loadable sections found in added symbol-file %s"),
d60484c
+	     objfile->name);
d60484c
+  else
d60484c
+    if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
d60484c
+      warning (_("Lowest section in %s is %s at %s"),
d60484c
+	       objfile->name,
d60484c
+	       bfd_section_name (objfile->obfd, lower_sect),
d60484c
+	       paddr (bfd_section_vma (objfile->obfd, lower_sect)));
d60484c
+  if (lower_sect != NULL)
d60484c
+    return bfd_section_vma (objfile->obfd, lower_sect);
d60484c
+  else
d60484c
+    return 0;
d60484c
+}
d60484c
 
d60484c
 /* Process a symbol file, as either the main file or as a dynamically
d60484c
    loaded file.
d60484c
@@ -696,32 +727,11 @@ syms_from_objfile (struct objfile *objfi
d60484c
      happens for the PA64 port.  */
d60484c
   if (/*!mainline &&*/ addrs && addrs->other[0].name)
d60484c
     {
d60484c
-      asection *lower_sect;
d60484c
       asection *sect;
d60484c
-      CORE_ADDR lower_offset;
d60484c
+      CORE_ADDR lower_offset = 0;	/* Shut up the GCC warning.  */
d60484c
+      int lower_offset_set = 0;
d60484c
       int i;
d60484c
 
d60484c
-      /* Find lowest loadable section to be used as starting point for
d60484c
-         continguous sections. FIXME!! won't work without call to find
d60484c
-	 .text first, but this assumes text is lowest section. */
d60484c
-      lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
d60484c
-      if (lower_sect == NULL)
d60484c
-	bfd_map_over_sections (objfile->obfd, find_lowest_section,
d60484c
-			       &lower_sect);
d60484c
-      if (lower_sect == NULL)
d60484c
-	warning (_("no loadable sections found in added symbol-file %s"),
d60484c
-		 objfile->name);
d60484c
-      else
d60484c
-	if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
d60484c
-	  warning (_("Lowest section in %s is %s at %s"),
d60484c
-		   objfile->name,
d60484c
-		   bfd_section_name (objfile->obfd, lower_sect),
d60484c
-		   paddr (bfd_section_vma (objfile->obfd, lower_sect)));
d60484c
-      if (lower_sect != NULL)
d60484c
- 	lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
d60484c
-      else
d60484c
- 	lower_offset = 0;
d60484c
-
d60484c
       /* Calculate offsets for the loadable sections.
d60484c
  	 FIXME! Sections must be in order of increasing loadable section
d60484c
  	 so that contiguous sections can use the lower-offset!!!
d60484c
@@ -743,6 +753,7 @@ syms_from_objfile (struct objfile *objfi
d60484c
                     addrs->other[i].addr
d60484c
                       -= bfd_section_vma (objfile->obfd, sect);
d60484c
                     lower_offset = addrs->other[i].addr;
d60484c
+		    lower_offset_set = 1;
d60484c
                     /* This is the index used by BFD. */
d60484c
                     addrs->other[i].sectindex = sect->index ;
d60484c
                   }
d60484c
@@ -755,7 +766,17 @@ syms_from_objfile (struct objfile *objfi
d60484c
                   }
d60484c
               }
d60484c
             else
d60484c
-              addrs->other[i].addr = lower_offset;
d60484c
+	      {
d60484c
+		/* Delay finding LOWER_OFFSET only if it is needed.  Otherwise
d60484c
+		   we would print a warning to detect a values never used.  */
d60484c
+		if (!lower_offset_set)
d60484c
+		  {
d60484c
+		    lower_offset = find_lower_offset (objfile);
d60484c
+		    lower_offset_set = 1;
d60484c
+		  }
d60484c
+
d60484c
+		addrs->other[i].addr = lower_offset;
d60484c
+	      }
d60484c
           }
d60484c
     }
d60484c