]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 22 Apr 2010 23:20:15 +0000 (23:20 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 22 Apr 2010 23:20:15 +0000 (23:20 +0000)
* symfile.c (addr_info_make_relative): Move sect declaration to the
outer block.  Initialize it to NULL.  Prefer SECT->next more than
bfd_get_section_by_name.

gdb/testsuite/
* gdb.base/dup-sect.exp, gdb.base/dup-sect.S: New.

gdb/ChangeLog
gdb/symfile.c
gdb/testsuite/ChangeLog

index 1a96104f72ff55b35ec42c29514cb7b9cc2e0b70..ede39492d9836722bbc0147fc92a9e440bbc82b0 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * symfile.c (addr_info_make_relative): Move sect declaration to the
+       outer block.  Initialize it to NULL.  Prefer SECT->next more than
+       bfd_get_section_by_name.
+
 2010-04-08  Sami Wagiaalla  <swagiaal@redhat.com>
 
        PR Breakpoints/11408:
index 9c28fb0d9a2412af92a014c734fef3ee1b5e58e2..6f136516ab2558cc1079973259df1f93e7158c52 100644 (file)
@@ -566,6 +566,7 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
   asection *lower_sect;
   CORE_ADDR lower_offset;
   int i;
+  asection *sect;
 
   /* Find lowest loadable section to be used as starting point for
      continguous sections.  */
@@ -590,10 +591,23 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
      (the loadable section directly below it in memory).
      this_offset = lower_offset = lower_addr - lower_orig_addr */
 
+  sect = NULL;
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
     {
-      asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
+      const char *sect_name = addrs->other[i].name;
+
+      /* Prefer the next section of that we have found last.  The separate
+        debug info files have either the same section layout or just a few
+        sections are missing there.  On the other hand the section name is not
+        unique and we could find an inappropraite section by its name.  */
+
+      if (sect)
+       sect = sect->next;
+      if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
+       sect = NULL;
 
+      if (sect == NULL)
+       sect = bfd_get_section_by_name (abfd, sect_name);
       if (sect)
        {
          /* This is the index used by BFD. */
index fa35e2c9dcc47610bb52d81e9ef5d51e25ebc784..7e386507e85376619a773cf884854e7ebf544636 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.base/dup-sect.exp, gdb.base/dup-sect.S: New.
+
 2010-04-08  Sami Wagiaalla  <swagiaal@redhat.com>
 
        * gdb.cp/gdb2384-base.h: Created 'namespace B'.