File execstack.patch of Package ghc
From 3739e565f8fa09b3a31ba8f563c518480585f6f9 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Sat, 11 Jun 2022 23:29:24 +0200
Subject: [PATCH] RTS: Add stack marker to StgCRunAsm.S
Every object file must be properly marked for non-executable stack, even if it
contains no code.
---
rts/StgCRunAsm.S | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/rts/StgCRunAsm.S b/rts/StgCRunAsm.S
index aed3241d12..9216e6c759 100644
--- a/rts/StgCRunAsm.S
+++ b/rts/StgCRunAsm.S
@@ -66,8 +66,6 @@ StgReturn:
addi 12,1,-(8*18)
bl _restgpr1_14
b _restfpr_14
-
- .section .note.GNU-stack,"",@progbits
# else // linux_HOST_OS
# error Only Linux support for power64 little endian right now.
# endif
@@ -231,8 +229,6 @@ StgReturn:
.cfi_endproc
.size StgReturn, .-StgReturn
- .section .note.GNU-stack,"",@progbits
-
#elif defined(riscv64_HOST_ARCH)
# define STACK_FRAME_SIZE (RESERVED_C_STACK_BYTES+208)
.text
@@ -374,8 +370,11 @@ StgReturn:
ret
.cfi_endproc
.size StgReturn, .-StgReturn
-
- .section .note.GNU-stack,"",@progbits
#endif
#endif /* !USE_MINIINTERPRETER */
+
+/* mark stack as nonexecutable */
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",@progbits
+#endif
--
2.37.0