*** ../binutils-2.21.53.0.1.orig/binutils/objcopy.c 2011-12-14 09:57:44.013157749 +0000
--- binutils/objcopy.c 2011-12-14 10:13:12.380183483 +0000
*************** is_specified_symbol (const char *name, h
*** 901,910 ****
return htab_find (htab, name) != NULL;
}
! /* See if a section is being removed. */
static bfd_boolean
! is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
{
if (sections_removed || sections_copied)
{
--- 901,910 ----
return htab_find (htab, name) != NULL;
}
! /* See if a non-group section is being removed. */
static bfd_boolean
! is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
{
if (sections_removed || sections_copied)
{
*************** is_strip_section (bfd *abfd ATTRIBUTE_UN
*** 931,940 ****
--- 931,952 ----
return FALSE;
}
+ return FALSE;
+ }
+
+ /* See if a section is being removed. */
+
+ static bfd_boolean
+ is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
+ {
+ if (is_strip_section_1 (abfd, sec))
+ return TRUE;
+
if ((bfd_get_section_flags (abfd, sec) & SEC_GROUP) != 0)
{
asymbol *gsym;
const char *gname;
+ asection *elt, *first;
/* PR binutils/3181
If we are going to strip the group signature symbol, then
*************** is_strip_section (bfd *abfd ATTRIBUTE_UN
*** 948,953 ****
--- 960,978 ----
&& !is_specified_symbol (gname, keep_specific_htab))
|| is_specified_symbol (gname, strip_specific_htab))
return TRUE;
+
+ /* Remove the group section if all members are removed. */
+ first = elt = elf_next_in_group (sec);
+ while (elt != NULL)
+ {
+ if (!is_strip_section_1 (abfd, elt))
+ return FALSE;
+ elt = elf_next_in_group (elt);
+ if (elt == first)
+ break;
+ }
+
+ return TRUE;
}
return FALSE;