]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
backport 2008-09-28 Alan Modra <amodra@bigpond.net.au>
authorAlan Modra <amodra@gmail.com>
Mon, 2 Mar 2009 13:31:14 +0000 (13:31 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 2 Mar 2009 13:31:14 +0000 (13:31 +0000)
bfd/ChangeLog
bfd/elf.c
bfd/elflink.c
binutils/ChangeLog
binutils/objcopy.c

index e925156ea8446c451ef4cecaa8aa28d5d8f0b487..d06b105f50ae09bfa6c74848d6ccc10891136dfb 100644 (file)
@@ -1,3 +1,11 @@
+2009-03-02  Alan Modra  <amodra@bigpond.net.au>
+
+       2008-09-28  Alan Modra  <amodra@bigpond.net.au>
+       * elf.c (_bfd_elf_init_private_section_data): Tweak union copy.
+       (bfd_section_from_shdr): Don't change SHT_GROUP section name.
+       * elflink.c (section_signature): New function.
+       (_bfd_elf_section_already_linked): Use it.
+
 2009-02-15  Bjoern Haase  <bjoern.m.haase@web.de>
 
        PR 9841
index 8639a5d565260ffca2318dd6c6a5eabf6451ffa9..04280a2e7e3c8885dfd38b9df97946107361088e 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1863,14 +1863,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
       return TRUE;
 
     case SHT_GROUP:
-      /* We need a BFD section for objcopy and relocatable linking,
-        and it's handy to have the signature available as the section
-        name.  */
       if (! IS_VALID_GROUP_SECTION_HEADER (hdr))
        return FALSE;
-      name = group_signature (abfd, hdr);
-      if (name == NULL)
-       return FALSE;
       if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
        return FALSE;
       if (hdr->contents != NULL)
@@ -6004,7 +5998,7 @@ _bfd_elf_init_private_section_data (bfd *ibfd,
          if (elf_section_flags (isec) & SHF_GROUP)
            elf_section_flags (osec) |= SHF_GROUP;
          elf_next_in_group (osec) = elf_next_in_group (isec);
-         elf_group_name (osec) = elf_group_name (isec);
+         elf_section_data (osec)->group = elf_section_data (isec)->group;
        }
     }
 
index 010c6141abb8f4bbb4cefc61c917d3b18ac7a8c0..24be41434204c0a88bdd5bfbe439544fec356f30 100644 (file)
@@ -11982,8 +11982,21 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
   return ret;
 }
 
+/* For a SHT_GROUP section, return the group signature.  For other
+   sections, return the normal section name.  */
+
+static const char *
+section_signature (asection *sec)
+{
+  if ((sec->flags & SEC_GROUP) != 0
+      && elf_next_in_group (sec) != NULL
+      && elf_group_name (elf_next_in_group (sec)) != NULL)
+    return elf_group_name (elf_next_in_group (sec));
+  return sec->name;
+}
+
 void
-_bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec,
+_bfd_elf_section_already_linked (bfd *abfd, asection *sec,
                                 struct bfd_link_info *info)
 {
   flagword flags;
@@ -12023,7 +12036,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec,
      causes trouble for MIPS ELF, which relies on link once semantics
      to handle the .reginfo section correctly.  */
 
-  name = bfd_get_section_name (abfd, sec);
+  name = section_signature (sec);
 
   if (CONST_STRNEQ (name, ".gnu.linkonce.")
       && (p = strchr (name + sizeof (".gnu.linkonce.") - 1, '.')) != NULL)
@@ -12038,7 +12051,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section *sec,
       /* We may have 2 different types of sections on the list: group
         sections and linkonce sections.  Match like sections.  */
       if ((flags & SEC_GROUP) == (l->sec->flags & SEC_GROUP)
-         && strcmp (name, l->sec->name) == 0
+         && strcmp (name, section_signature (l->sec)) == 0
          && bfd_coff_get_comdat_section (l->sec->owner, l->sec) == NULL)
        {
          /* The section has already been linked.  See if we should
index 7ce67a058409bc6ccb983af1d4b9d1bb19746c8f..a458bbd5b9eed3342a546979ecdb0188ee54d74e 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-02  Alan Modra  <amodra@bigpond.net.au>
+
+       2008-09-28  Alan Modra  <amodra@bigpond.net.au>
+       * objcopy.c (setup_section): Set elf_group_id.
+
 2008-12-23  Nick Clifton  <nickc@redhat.com>
 
        * windmc.c (main): Use correct type for file length.
index deff1697e9b221de9009a21727dec2770d0a3218..f8c1732fb2cd07a5dca0a9ea277a46639feb7149 100644 (file)
@@ -2344,6 +2344,18 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
   if (extract_symbol)
     return;
 
+  if ((isection->flags & SEC_GROUP) != 0)
+    {
+      asymbol *gsym = group_signature (isection);
+
+      if (gsym != NULL)
+       {
+         gsym->flags |= BSF_KEEP;
+         if (ibfd->xvec->flavour == bfd_target_elf_flavour)
+           elf_group_id (isection) = gsym;
+       }
+    }
+
   /* Allow the BFD backend to copy any private data it understands
      from the input section to the output section.  */
   if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
@@ -2351,13 +2363,6 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
       err = _("failed to copy private data");
       goto loser;
     }
-  else if ((isection->flags & SEC_GROUP) != 0)
-    {
-      asymbol *gsym = group_signature (isection);
-
-      if (gsym != NULL)
-       gsym->flags |= BSF_KEEP;
-    }
 
   /* All went well.  */
   return;