https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97827
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Draft patch (untested):
diff --git a/gcc/varasm.c b/gcc/varasm.c
index ada99940f65..51a507393a8 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6738,9 +6738,11 @@ default_elf_asm_named_section (const char *name,
unsigned int flags,
/* If we have already declared this section, we can use an
abbreviated form to switch back to it -- unless this section is
part of a COMDAT groups, in which case GAS requires the full
- declaration every time. */
+ declaration every time. LLVM's MC linker requires that the
+ flags are identical, thus avoid the abbreviated form with MERGE. */
if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
- && (flags & SECTION_DECLARED))
+ && (flags & SECTION_DECLARED)
+ && !(flags & SECTION_MERGE))
{
fprintf (asm_out_file, "\t.section\t%s\n", name);
return;