[PATCH] Implement objcopy/strip --keep-section=<sectionpattern>
FÃÂng-ruì Sòng via binutils
binutils@sourceware.org
Fri Nov 1 21:48:00 GMT 2019
On Fri, Nov 1, 2019 at 12:00 AM Alan Modra <amodra@gmail.com> wrote:
>
> On Thu, Oct 31, 2019 at 09:16:03PM -0700, Fāng-ruì Sòng wrote:
> > On Thu, Oct 31, 2019 at 7:00 PM Alan Modra <amodra@gmail.com> wrote:
> > >
> > > On Thu, Oct 31, 2019 at 05:06:58PM -0700, Fāng-ruì Sòng via binutils wrote:
> > > > + * objcopy.c (enum option_values): Add OPTION_KEEP_SECTION.
> > > > + (SECTION_CONTEXT_KEEP): New macro.
> > >
> > > This needs to be more detailed. You haven't mentioned that you are
> > > changing the other macros, nor have you mentioned the functions you
> > > are changing in objcopy.c. The NEWS, binutils.texi, and testsuite
> > > changes also need entries in the ChangeLog.
> > > For the macro changes,
> > > (SECTION_CONTEXT_KEEP): Define. Adjust other SECTION_CONTEXT macros.
> > > would be sufficient.
> >
> > Thanks. Changed in the updated patch.
>
> Still not complete.
Added some more items, but not clear whether they are complete now.
When can we stop writing ChangeLogs (looking at glibc)?
If it is still incomplete, I hope a maintainer can help writing it.
> > > > @@ -1367,6 +1373,10 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
> > > > static bfd_boolean
> > > > is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
> > > > {
> > > > + if (find_section_list (bfd_section_name (sec), FALSE, SECTION_CONTEXT_KEEP)
> > > > + != NULL)
> > > > + return FALSE;
> > > > +
> > > > if (is_strip_section_1 (abfd, sec))
> > > > return TRUE;
> > > >
> > >
> > > I believe this change should be made in is_strip_section_1 instead.
> > > Otherwise, with a proper ChangeLog entry the patch looks good to
> > > commit.
> >
> > is_strip_section_1 returns either TRUE (strip the section) or FALSE
> > (fall through to other conditions). We cannot put the --keep-section
> > logic there.
>
> Those "other conditions" are precisely why you should put the new
> --keep-section logic in is_strip_section_1. Really. SEC_GROUP is
> special.
Moved from is_strip_section to is_strip_section_1.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: objcopy-keep-section.patch
Type: text/x-patch
Size: 11151 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20191101/bc93c229/attachment.bin>
More information about the Binutils
mailing list