From e99cf237f84db34be0468a893b10394d6b364bce Mon Sep 17 00:00:00 2001
From: Moritz Angermann <moritz.angermann@gmail.com>
Date: Tue, 10 Oct 2023 14:25:29 +0800
Subject: [PATCH] nativeGen: section flags for .text$foo only

Commit 3ece9856d157c85511d59f9f862ab351bbd9b38b, was supposed to fix
#22834 in !9810.

It does however add "xr" indiscriminatly to .text sections
even if splitSections is disabled. This leads to the assembler saying:

ghc_1.s:7849:0: error:
     Warning: Ignoring changed section attributes for .text
     |
7849 | .section .text,"xr"
     | ^
---
 compiler/GHC/CmmToAsm/Ppr.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/compiler/GHC/CmmToAsm/Ppr.hs b/compiler/GHC/CmmToAsm/Ppr.hs
index 45b0545059e9..967391d25f87 100644
--- a/compiler/GHC/CmmToAsm/Ppr.hs
+++ b/compiler/GHC/CmmToAsm/Ppr.hs
@@ -246,9 +246,10 @@ pprGNUSectionHeader config t suffix =
         panic "PprBase.pprGNUSectionHeader: unknown section type"
     flags = case t of
       Text
-        | OSMinGW32 <- platformOS platform
+        | OSMinGW32 <- platformOS platform, splitSections
                     -> text ",\"xr\""
-        | otherwise -> text ",\"ax\"," <> sectionType platform "progbits"
+        | splitSections
+                    -> text ",\"ax\"," <> sectionType platform "progbits"
       CString
         | OSMinGW32 <- platformOS platform
                     -> empty
-- 
GitLab