diff --git a/runtime/druntime/src/core/thread/fiber/switch_context_asm.S b/runtime/druntime/src/core/thread/fiber/switch_context_asm.S index 77d0067497..659baf0778 100644 --- a/runtime/druntime/src/core/thread/fiber/switch_context_asm.S +++ b/runtime/druntime/src/core/thread/fiber/switch_context_asm.S @@ -13,13 +13,13 @@ * http://www.boost.org/LICENSE_1_0.txt) */ -#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__ +#if __ELF__ /* * Mark the resulting object file as not requiring execution permissions on * stack memory. The absence of this section would mark the whole resulting * library as requiring an executable stack, making it impossible to - * dynamically load druntime on several Linux platforms where this is - * forbidden due to security policies. + * dynamically load druntime on several platforms where this is forbidden + * due to security policies. */ .section .note.GNU-stack,"",%progbits #endif diff --git a/runtime/druntime/src/core/thread/fiber/switch_context_riscv.S b/runtime/druntime/src/core/thread/fiber/switch_context_riscv.S index 68e2a9bd3c..d76a6bdbac 100644 --- a/runtime/druntime/src/core/thread/fiber/switch_context_riscv.S +++ b/runtime/druntime/src/core/thread/fiber/switch_context_riscv.S @@ -6,6 +6,18 @@ * Authors: Denis Feklushkin */ +#if __ELF__ +/* + * Mark the resulting object file as not requiring execution permissions on + * stack memory. The absence of this section would mark the whole resulting + * library as requiring an executable stack, making it impossible to + * dynamically load druntime on several platforms where this is forbidden + * due to security policies. + */ +.section .note.GNU-stack,"",%progbits +#endif + + #if defined(__riscv) // For save/load a register in memory, regardless of the size of machine register bit size diff --git a/runtime/druntime/src/ldc/eh_asm.S b/runtime/druntime/src/ldc/eh_asm.S index f7b6b30dc6..e303a77f2b 100644 --- a/runtime/druntime/src/ldc/eh_asm.S +++ b/runtime/druntime/src/ldc/eh_asm.S @@ -6,15 +6,14 @@ * License: Boost License 1.0. */ +#if __ELF__ /* * Mark the resulting object file as not requiring execution * permissions on stack memory. The absence of this section would mark * the whole resulting library as requiring an executable stack, - * making it impossible to dynamically load druntime on several Linux + * making it impossible to dynamically load druntime on several * platforms where this is forbidden due to security policies. */ - -#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__) .section .note.GNU-stack,"",%progbits .previous #endif