summaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-09-16 04:23:16 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-09-16 04:23:16 +0000
commit4881b5a74d060579acc960014a1cedab713e6591 (patch)
tree29a1d223877b4c089d6bbb799c14abf9716fc938 /binutils/objcopy.c
parent3475fe928892df696f6ea9b2c912e1379591e736 (diff)
downloadbinutils-redhat-4881b5a74d060579acc960014a1cedab713e6591.tar.gz
Remove the group section if all members are removed.
binutils/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR binutils/13180 * objcopy.c (is_strip_section_1): New. (is_strip_section): Use it. Remove the group section if all members are removed. binutils/testsuite/ 2011-09-15 H.J. Lu <hongjiu.lu@intel.com> PR binutils/13180 * binutils-all/group-6.d: New. * binutils-all/group-6.s: Likewise. * binutils-all/objcopy.exp: Run group-6 for ELF targrts.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index b64f3d046c..31ac0a2bb3 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -925,10 +925,10 @@ group_signature (asection *group)
return NULL;
}
-/* See if a section is being removed. */
+/* See if a non-group section is being removed. */
static bfd_boolean
-is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
+is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
{
if (sections_removed || sections_copied)
{
@@ -955,10 +955,22 @@ is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
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
@@ -972,6 +984,19 @@ is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
&& !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;