https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123791
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think we should go for
--- gcc/config/aarch64/aarch64.cc.jj 2026-01-20 15:38:17.961016992 +0100
+++ gcc/config/aarch64/aarch64.cc 2026-01-23 16:02:13.054416068 +0100
@@ -14315,9 +14315,17 @@ aarch64_select_rtx_section (machine_mode
if (aarch64_can_use_per_function_literal_pools_p ())
return function_section (current_function_decl);
- /* When using anchors for constants use the readonly section. */
+ /* When using anchors for constants use the readonly section,
+ unless x has needs relocations in -fno-pic or is a comdat
+ group private reference. */
if (known_le (GET_MODE_SIZE (mode), 8))
- return readonly_data_section;
+ {
+ int save_flag_merge_constants = flag_merge_constants;
+ flag_merge_constants = 0;
+ section *ret = default_elf_select_rtx_section (mode, x, align);
+ flag_merge_constants = save_flag_merge_constants;
+ return ret;
+ }
return default_elf_select_rtx_section (mode, x, align);
}
I.e. let default_elf_select_rtx_section handle everything needed, just prevent
using mergeable sections during that call.