https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118889
--- Comment #5 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
...the respective part of varasm.cc reads:
get_variable_section (tree decl, bool prefer_noswitch_p)
{
...
if (ADDR_SPACE_GENERIC_P (as)
&& !DECL_THREAD_LOCAL_P (decl)
&& !DECL_NOINIT_P (decl)
&& !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
&& bss_initializer_p (decl))
{
if (!TREE_PUBLIC (decl)
&& !((flag_sanitize & SANITIZE_ADDRESS)
&& asan_protect_global (decl)))
return lcomm_section;
if (bss_noswitch_section)
return bss_noswitch_section;
}
return targetm.asm_out.select_section (decl, reloc,
get_variable_align (decl));
}
Plus, what also does not work is to add a "noinit" attribute to coax
into calling targetm.asm_out.select_section, since with "noinit"
and -fdata-sections, the object if effectively in a named section.
And named sections don't have a section callback, so no custom asm
is possible.