aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-08-04 08:26:38 +0000
committerAlan Modra <amodra@gmail.com>2007-08-04 08:26:38 +0000
commit6612555199a45a60bad366e8697bb53d3d128175 (patch)
tree56bf66c3b2bcfc1371a6fc784f4523e44d1e446a /binutils
parent474d0d0c7af3f155a53223d1a4b6951aed2e30dc (diff)
downloadgdb-6612555199a45a60bad366e8697bb53d3d128175.zip
gdb-6612555199a45a60bad366e8697bb53d3d128175.tar.gz
gdb-6612555199a45a60bad366e8697bb53d3d128175.tar.bz2
PR 4888
* objcopy.c (setup_section): Do modify section flags for ELF STRIP_NONDEBUG (reverting part of 2007-05-30 change). Prevent header rewrite by twiddling input section flags instead. Simplify code setting SHT_NOBITS.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/objcopy.c29
2 files changed, 27 insertions, 10 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 2e71518..2b88341 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2007-08-04 Alan Modra <amodra@bigpond.net.au>
+
+ PR 4888
+ * objcopy.c (setup_section): Do modify section flags for ELF
+ STRIP_NONDEBUG (reverting part of 2007-05-30 change). Prevent
+ header rewrite by twiddling input section flags instead.
+ Simplify code setting SHT_NOBITS.
+
2007-07-28 Christopher Faylor <me+binutils@cgf.cx>
* MAINTAINERS: Update my email address.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index b993276..e577dd3 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2165,6 +2165,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
const char *err;
const char * name;
char *prefix = NULL;
+ bfd_boolean make_nobits;
if (is_strip_section (ibfd, isection))
return;
@@ -2193,12 +2194,26 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
name = n;
}
+ make_nobits = FALSE;
if (p != NULL && p->set_flags)
flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
else if (strip_symbols == STRIP_NONDEBUG
- && obfd->xvec->flavour != bfd_target_elf_flavour
- && (flags & SEC_ALLOC) != 0)
- flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+ && (flags & SEC_ALLOC) != 0
+ && (ibfd->xvec->flavour != bfd_target_elf_flavour
+ || elf_section_type (isection) != SHT_NOTE))
+ {
+ flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+ if (obfd->xvec->flavour == bfd_target_elf_flavour)
+ {
+ make_nobits = TRUE;
+
+ /* Twiddle the input section flags so that it seems to
+ 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);
+ }
+ }
osection = bfd_make_section_anyway_with_flags (obfd, name, flags);
@@ -2208,13 +2223,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
goto loser;
}
- if (strip_symbols == STRIP_NONDEBUG
- && obfd->xvec->flavour == bfd_target_elf_flavour
- && (flags & SEC_ALLOC) != 0
- && elf_section_type (osection) != SHT_NOTE
- && (ibfd->xvec->flavour != bfd_target_elf_flavour
- || elf_section_type (isection) != SHT_NOTE)
- && (p == NULL || !p->set_flags))
+ if (make_nobits)
elf_section_type (osection) = SHT_NOBITS;
size = bfd_section_size (ibfd, isection);