https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123791

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> 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);
>  }


How about this doing this instead:
 /* When using anchors for constants use the readonly section
    that would have been a mergeble section.  */
section *s = default_elf_select_rtx_section (mode, x, align);
if ((s->flags & SECTION_MERGE) && known_le (GET_MODE_SIZE (mode), 8))
  return readonly_data_section;

Reply via email to