From: Alan Modra Date: Mon, 2 Mar 2009 13:31:14 +0000 (+0000) Subject: backport 2008-09-28 Alan Modra X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ac7046d0e88698cf28da5f25f93a7fe263e3784;p=thirdparty%2Fbinutils-gdb.git backport 2008-09-28 Alan Modra --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e925156ea84..d06b105f50a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2009-03-02 Alan Modra + + 2008-09-28 Alan Modra + * 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 PR 9841 diff --git a/bfd/elf.c b/bfd/elf.c index 8639a5d5652..04280a2e7e3 100644 --- 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; } } diff --git a/bfd/elflink.c b/bfd/elflink.c index 010c6141abb..24be4143420 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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 diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7ce67a05840..a458bbd5b9e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2009-03-02 Alan Modra + + 2008-09-28 Alan Modra + * objcopy.c (setup_section): Set elf_group_id. + 2008-12-23 Nick Clifton * windmc.c (main): Use correct type for file length. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index deff1697e9b..f8c1732fb2c 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -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;