This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Alternative fix for PR3166
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 29 Jun 2010 18:16:41 +0930
- Subject: Alternative fix for PR3166
I've had this patch in my tree for a while, and forget why I happened
to revisit the PR. Possibly when looking at an oprofile problem with
separate debug info files. Anyway, the disadvantage of totally
removing group sections for --only-keep-debug is that the debug info
file sections don't match up with the original file. We are supposed
to keep the same sections but make them SHT_NOBITS.
PR binutils/3166
* objcopy (is_strip_section): Revert 2006-09-05.
(setup_section): Make SHT_GROUP section nobits.
Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.142
diff -u -p -r1.142 objcopy.c
--- binutils/objcopy.c 1 Feb 2010 09:59:46 -0000 1.142
+++ binutils/objcopy.c 28 Jun 2010 15:36:28 -0000
@@ -942,12 +942,6 @@ is_strip_section (bfd *abfd ATTRIBUTE_UN
asymbol *gsym;
const char *gname;
- /* PR binutils/3166
- Group sections look like debugging sections but they are not.
- (They have a non-zero size but they are not ALLOCated). */
- if (strip_symbols == STRIP_NONDEBUG)
- return TRUE;
-
/* PR binutils/3181
If we are going to strip the group signature symbol, then
strip the group section too. */
@@ -2419,11 +2413,11 @@ setup_section (bfd *ibfd, sec_ptr isecti
if (p != NULL && p->set_flags)
flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
else if (strip_symbols == STRIP_NONDEBUG
- && (flags & SEC_ALLOC) != 0
- && (ibfd->xvec->flavour != bfd_target_elf_flavour
- || elf_section_type (isection) != SHT_NOTE))
+ && (flags & (SEC_ALLOC | SEC_GROUP)) != 0
+ && !(ibfd->xvec->flavour == bfd_target_elf_flavour
+ && elf_section_type (isection) == SHT_NOTE))
{
- flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+ flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP);
if (obfd->xvec->flavour == bfd_target_elf_flavour)
{
make_nobits = TRUE;
@@ -2432,7 +2426,7 @@ setup_section (bfd *ibfd, sec_ptr isecti
elf.c:copy_private_bfd_data that section flags have not
changed between input and output sections. This hack
prevents wholesale rewriting of the program headers. */
- isection->flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+ isection->flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD | SEC_GROUP);
}
}
--
Alan Modra
Australia Development Lab, IBM