On Mon, Feb 15, 2021 at 02:35:07PM -0800, H.J. Lu via Gcc-patches wrote:
> When building Linux kernel, ld in bninutils 2.36 with GCC 11 generates
> thousands of
> 
> ld: warning: orphan section `.data.event_initcall_finish' from `init/main.o' 
> being placed in section `.data.event_initcall_finish'
> ld: warning: orphan section `.data.event_initcall_start' from `init/main.o' 
> being placed in section `.data.event_initcall_start'
> ld: warning: orphan section `.data.event_initcall_level' from `init/main.o' 
> being placed in section `.data.event_initcall_level'
> 
> Since these sections are marked with SHF_GNU_RETAIN, they are placed in
> separate sections.  They become orphan sections since they aren't expected
> in the Linux kernel linker script. But orphan sections normally don't work
> well with the Linux kernel linker script and the resulting kernel crashed.
> 
> Add -fgnu-retain to disable SHF_GNU_RETAIN for Linux kernel build with
> -fno-gnu-retain.

I'd say this shows that the changing of meaning of "used" attribute wasn't
really a good idea, the Linux kernel certainly won't be the only problem
and people use "used" attribute for many reasons and don't necessarily want
the different sections or different behavior of those sections if they use
it.

So, can't we instead:
1) restore the old behavior of "used" by default
2) add "retain" attribute that implies the SHF_GNU_RETAIN stuff and fails
   if the configured assembler/linker doesn't support those
3) add a non-default option through which one could opt in for "used"
   attribute to imply retain attribute too for projects that want that?

        Jakub

Reply via email to