This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix strip bug with SHF_MERGE sections
On Sat, Dec 08, 2001 at 07:07:16PM -0800, Richard Henderson wrote:
> On Sat, Dec 08, 2001 at 10:59:49PM +0100, Jakub Jelinek wrote:
> > * objcopy.c (setup_section): Copy entsize for SEC_MERGE sections.
>
> Seems like this should be done regardless of SEC_MERGE.
Well, at the moment, entsize is declared:
/* Entity size for merging purposes. */
unsigned int entsize;
and used for SEC_MERGE only.
I agree that it can be copied unconditionally, just SEC_MERGE needs to be
cleared if the input section was not SEC_MERGE (flags can change e.g.
because of section rename options).
Is this better?
2001-12-09 Jakub Jelinek <jakub@redhat.com>
* objcopy.c (setup_section): Copy entsize.
--- binutils/objcopy.c.jj Tue Oct 2 00:25:22 2001
+++ binutils/objcopy.c Sun Dec 9 13:49:13 2001
@@ -1596,12 +1596,21 @@ setup_section (ibfd, isection, obfdarg)
if (p != NULL && p->set_flags)
flags = p->flags | (flags & SEC_HAS_CONTENTS);
+
+ /* Clear SEC_MERGE if entsize is not valid. */
+ if ((bfd_get_section_flags (ibfd, isection) & (SEC_MERGE | SEC_STRINGS))
+ != (flags & (SEC_MERGE | SEC_STRINGS)))
+ flags &= ~(SEC_MERGE | SEC_STRINGS);
+
if (!bfd_set_section_flags (obfd, osection, flags))
{
err = _("flags");
goto loser;
}
+ /* Copy entsize. */
+ osection->entsize = isection->entsize;
+
/* This used to be mangle_section; we do here to avoid using
bfd_get_section_by_name since some formats allow multiple
sections with the same name. */
Jakub