[PATCH v4] Support SHF_GNU_RETAIN ELF section flag

Jozef Lawrynowicz jozef.l@mittosystems.com
Mon Nov 9 16:00:03 GMT 2020


On Mon, Nov 09, 2020 at 07:24:56AM -0800, H.J. Lu via Binutils wrote:
> On Tue, Nov 3, 2020 at 12:02 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Tue, Nov 3, 2020 at 10:11 AM Jozef Lawrynowicz
> > <jozef.l@mittosystems.com> wrote:
> > >
> > > On Tue, Nov 03, 2020 at 09:43:36AM -0800, H.J. Lu via Binutils wrote:
> > > > On Tue, Nov 3, 2020 at 9:33 AM Jozef Lawrynowicz
> > > > <jozef.l@mittosystems.com> wrote:
> > > > >
> > > > > The attached patch is the latest version of the Binutils implementation
> > > > > to support the SHF_GNU_RETAIN ELF GNU OSABI section flag, used to save
> > > > > sections from linker garbage collection.
> > > > >
> > > > > Links to previous discussions are available here:
> > > > > https://sourceware.org/pipermail/gnu-gabi/2020q3/000429.html
> > > > > https://sourceware.org/pipermail/binutils/2020-September/113406.html
> > > > > https://sourceware.org/pipermail/binutils/2020-October/113559.html
> > > > > https://sourceware.org/pipermail/binutils/2020-October/113769.html
> > > > >
> > > > > The intention with this latest patch is to support declarations in the
> > > > > source code marked with the "used" attribute being saved from linker
> > > > > garbage collection. The previously discussed "retain" GCC attribute has
> > > > > been removed.
> > > > >
> > > > > For declarations marked with the "used" attribute, GCC will emit a
> > > > > ".retain <symname>" directive, where <symname> is the name of the
> > > > > symbol. This hooks into existing GCC functionality for marking a
> > > > > symbol as "preserved" (currently used only by Darwin).
> > > >
> > > > I don't believe that the .retain directive is needed.
> > >
> > > I know we previously discussed that a ".retain <section_name>" directive
> > > is not required, and I agree.
> > >
> > > However, ".retain <symbol_name>" to save the section containing the
> > > symbol is beneficial.
> > >
> >
> > See:
> >
> > https://gitlab.com/x86-gcc/gcc/-/commits/users/hjl/elf/shf_retain
> 
> Please remove the .retain directive.  It is ill-defined and not needed for
> SHF_GNU_RETAIN.

I'm currently polishing and testing a patch which removes .retain, in
conjunction with new GCC functionality.

Thanks,
Jozef
> 
> -- 
> H.J.


More information about the Binutils mailing list