cafa2ff
Fix i386-on-x86_64 debugging giving the warning:
cafa2ff
	warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4
cafa2ff
eb9d945
[base]
cafa2ff
eb9d945
2007-10-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
eb9d945
eb9d945
	Port to GDB-6.7.
eb9d945
8b1b3fd
Index: gdb-6.8/gdb/symfile.c
eb9d945
===================================================================
8b1b3fd
--- gdb-6.8.orig/gdb/symfile.c	2008-07-14 10:28:15.000000000 +0200
8b1b3fd
+++ gdb-6.8/gdb/symfile.c	2008-07-14 10:28:21.000000000 +0200
8b1b3fd
@@ -715,6 +715,38 @@ default_symfile_segments (bfd *abfd)
eb9d945
   return data;
cafa2ff
 }
cafa2ff
 
cafa2ff
+/* Find lowest loadable section to be used as starting point for continguous
cafa2ff
+   sections. FIXME!! won't work without call to find .text first, but this
cafa2ff
+   assumes text is lowest section.  vDSO was seen for i386-on-amd64 processes
cafa2ff
+   to have no `.text' as it has `.text.vsyscall', `.text.sigreturn' etc.
cafa2ff
+   instead.  Execution of this function has been delayed till it is really
cafa2ff
+   needed as it is broken for vDSOs, fortunately it is never needed on
cafa2ff
+   GNU/Linux.  */
cafa2ff
+
cafa2ff
+static CORE_ADDR
cafa2ff
+find_lower_offset (struct objfile *objfile)
cafa2ff
+{
cafa2ff
+  asection *lower_sect;
cafa2ff
+
cafa2ff
+  lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
cafa2ff
+  if (lower_sect == NULL)
cafa2ff
+    bfd_map_over_sections (objfile->obfd, find_lowest_section,
cafa2ff
+			   &lower_sect);
cafa2ff
+  if (lower_sect == NULL)
cafa2ff
+    warning (_("no loadable sections found in added symbol-file %s"),
cafa2ff
+	     objfile->name);
cafa2ff
+  else
cafa2ff
+    if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
cafa2ff
+      warning (_("Lowest section in %s is %s at %s"),
cafa2ff
+	       objfile->name,
cafa2ff
+	       bfd_section_name (objfile->obfd, lower_sect),
cafa2ff
+	       paddr (bfd_section_vma (objfile->obfd, lower_sect)));
cafa2ff
+  if (lower_sect != NULL)
cafa2ff
+    return bfd_section_vma (objfile->obfd, lower_sect);
cafa2ff
+  else
cafa2ff
+    return 0;
cafa2ff
+}
eb9d945
+
cafa2ff
 /* Process a symbol file, as either the main file or as a dynamically
cafa2ff
    loaded file.
eb9d945
 
8b1b3fd
@@ -813,32 +845,11 @@ syms_from_objfile (struct objfile *objfi
cafa2ff
      happens for the PA64 port.  */
8b1b3fd
   if (!mainline && addrs && addrs->other[0].name)
cafa2ff
     {
cafa2ff
-      asection *lower_sect;
cafa2ff
       asection *sect;
cafa2ff
-      CORE_ADDR lower_offset;
cafa2ff
+      CORE_ADDR lower_offset = 0;	/* Shut up the GCC warning.  */
cafa2ff
+      int lower_offset_set = 0;
cafa2ff
       int i;
cafa2ff
 
cafa2ff
-      /* Find lowest loadable section to be used as starting point for
cafa2ff
-         continguous sections. FIXME!! won't work without call to find
cafa2ff
-	 .text first, but this assumes text is lowest section. */
cafa2ff
-      lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
cafa2ff
-      if (lower_sect == NULL)
cafa2ff
-	bfd_map_over_sections (objfile->obfd, find_lowest_section,
cafa2ff
-			       &lower_sect);
cafa2ff
-      if (lower_sect == NULL)
cafa2ff
-	warning (_("no loadable sections found in added symbol-file %s"),
cafa2ff
-		 objfile->name);
cafa2ff
-      else
cafa2ff
-	if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0)
cafa2ff
-	  warning (_("Lowest section in %s is %s at %s"),
cafa2ff
-		   objfile->name,
cafa2ff
-		   bfd_section_name (objfile->obfd, lower_sect),
cafa2ff
-		   paddr (bfd_section_vma (objfile->obfd, lower_sect)));
cafa2ff
-      if (lower_sect != NULL)
cafa2ff
- 	lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
cafa2ff
-      else
cafa2ff
- 	lower_offset = 0;
cafa2ff
-
cafa2ff
       /* Calculate offsets for the loadable sections.
cafa2ff
  	 FIXME! Sections must be in order of increasing loadable section
cafa2ff
  	 so that contiguous sections can use the lower-offset!!!
8b1b3fd
@@ -860,6 +871,7 @@ syms_from_objfile (struct objfile *objfi
cafa2ff
                     addrs->other[i].addr
cafa2ff
                       -= bfd_section_vma (objfile->obfd, sect);
cafa2ff
                     lower_offset = addrs->other[i].addr;
eb9d945
+                    lower_offset_set = 1;
cafa2ff
                     /* This is the index used by BFD. */
cafa2ff
                     addrs->other[i].sectindex = sect->index ;
cafa2ff
                   }
8b1b3fd
@@ -872,7 +884,17 @@ syms_from_objfile (struct objfile *objfi
cafa2ff
                   }
cafa2ff
               }
cafa2ff
             else
cafa2ff
-              addrs->other[i].addr = lower_offset;
eb9d945
+              {
eb9d945
+                /* Delay finding LOWER_OFFSET only if it is needed.  Otherwise
eb9d945
+                   we would print a warning to detect a values never used.  */
eb9d945
+                if (!lower_offset_set)
eb9d945
+                  {
eb9d945
+                    lower_offset = find_lower_offset (objfile);
eb9d945
+                    lower_offset_set = 1;
eb9d945
+                  }
cafa2ff
+
eb9d945
+                addrs->other[i].addr = lower_offset;
eb9d945
+              }
cafa2ff
           }
cafa2ff
     }
cafa2ff