https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99113
Sergei Trofimovich <slyfox at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |slyfox at gcc dot gnu.org
--- Comment #2 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
I have a few notes:
1. GCC should put SHF_GNU_RETAIN section into a different section from .data
anyway, right?
I think that means linux kernel would need to adapt in any case to merge new
.data.${SHF_GNU_RETAIN_name} section into appropriate place in it's linker
script.
Proposal: rename a section in an easily distinguishable prefix, like:
NEW: .data.retain.event_initcall_finish
OLD: .data.event_initcall_finish
That would simplify tweaking linux ldscript. For -fno-function-sections case it
could be just.
.data.retain
Do we still have time for such a rename? Is it safe?
2. Linux kernel does support -ffunction-sections with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. But it relies even more on naming
conventions:
#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
#define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
#else
#define TEXT_MAIN .text
#define DATA_MAIN .data
#define SDATA_MAIN .sdata
#define RODATA_MAIN .rodata
#define BSS_MAIN .bss
#define SBSS_MAIN .sbss
#endif
A variant of [1.] would allow for easier section ganthering in the script.
3. I tried to add '.data.event*' (and similar) to linux ldscript and it was not
enough for me to built a kernel that does not crash. Which might hint at
binutils bug or linux loader bug (or at my bad attempt at adding sections).