[RFC] SHF_GNU_RETAIN ELF Section Flag
Jozef Lawrynowicz
jozef.l@mittosystems.com
Wed Sep 16 14:13:45 GMT 2020
On Wed, Sep 16, 2020 at 08:58:41AM -0400, Carlos O'Donell wrote:
> On 9/15/20 12:52 PM, Jozef Lawrynowicz wrote:
> > I suppose the most compelling use cases for SHF_GNU_RETAIN are when the
> > dependency cannot be expressed with references to ELF sections. You
> > can't use SHF_GROUP because there is nothing to group the section with.
>
> GRP_KEEP - Group of sections to always keep. Never discarded if included
> in the link.
>
> The benefit is you can give them a logical group name e.g. "cpu_features"
> and have more than one of them for accounting/documentation purposes.
>
> You can implement a "KEEP" source markup based on gas' .section directive?
This is an interesting idea, but my initial thoughts are that it adds
some complexity that I don't think is required. There is already a lot
of information that can be gleaned from the section header, and the
symbols within that section.
Presumably the developer would have named the ISR/memory mapped
register symbol sensibly.
It doesn't seem very standard to make use of ELF constructs for
documenting why something has been done a certain way. You would just
use the construct to make something happen and have the "why" documented
elsewhere.
On Wed, Sep 16, 2020 at 03:11:20PM +0200, Florian Weimer wrote:
> * Jozef Lawrynowicz:
>
> > I suppose the most compelling use cases for SHF_GNU_RETAIN are when the
> > dependency cannot be expressed with references to ELF sections. You
> > can't use SHF_GROUP because there is nothing to group the section with.
>
> But if there is nothing to group the section with, why would the link
> editor load the object?
>
> That's the part I don't understand.
Well this is intended for use by application code rather than libraries.
So all the objects that are part of the specific application and
explicitly passed to the link editor are going to be loaded.
(Please forgive any technical misuse of "application" above, but I hope
it is clear what I mean ;))
If a developer wants to use it in a library they'll have to take
precautions that it behaves as expected, by considering the object file
that the SHF_GNU_RETAIN section would reside in.
Thanks,
Jozef
More information about the Gnu-gabi
mailing list