On Thu, Feb 18, 2021 at 02:22:35PM +0000, Jozef Lawrynowicz wrote:
> I think it is a enhancement, and true to the spirit of the attribute,
> for "used" to save a symbol from linker garbage collection.
> 
> Why should "used" mean:
>   Save this symbol from compiler optimization, but allow the linker to
>   remove it.
> 
> I can't currently think of a use case where a "used" symbol should be
> kept by the compiler but removed by the linker.
> 
> Often we see KEEP directives in linker scripts accompanying
> "used" in the source code. libgcc/crtstuff.c is a good example. GNU
> linker scripts need many specific KEEP directives to handle all the
> "used" symbols.
> 
> If a developer marks a symbol as "used" in the source code, I think the
> intuitive thing is for that symbol to be present in the linked output
> file.

There are many reasons why a symbol is marked "used", one of the very often
seen ones is e.g. that the symbol is referenced from inline asm.
You don't need to guard such symbols against GC.

        Jakub

Reply via email to