[PATCH] Support SHF_GNU_RETAIN ELF section flag

Pedro Alves pedro@palves.net
Mon Sep 28 11:35:28 GMT 2020


On 9/22/20 9:29 PM, Jozef Lawrynowicz wrote:
> 
> The overall intention for this new flag is to enable a new "retain"
> attribute to be applied to declarations of functions and data in the
> source code. This attribute can be used to ensure the definition
> associated with the declaration is present in the linked output file,
> even if linker garbage collection would normally remove the containing
> section because it is unused.

On a high level, this sounds pretty much like __attribute__((used)).
Couldn't the new section flag be wired to that attribute?  

I mean, isn't it a bug if linker garbage collection eliminates a
function marked with __attribute__((used)) ?

 "used

   This attribute, attached to a function, means that code must be emitted 
   for the function even if it appears that the function is not referenced."

I was surprised to not see any mention of the "used" attribute in the
proposal, neither here, nor in gABI mailing list discussion linked.
But maybe I missed it.

Pedro Alves


More information about the Binutils mailing list