Skip to content

Commit fb26745

Browse files
authored
fiber/switch_context_riscv.S: disable executable stack (#4968)
Like it is done for the other assembly files, add the GNU-stack note. Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
1 parent 135c195 commit fb26745

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

runtime/druntime/src/core/thread/fiber/switch_context_asm.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* http://www.boost.org/LICENSE_1_0.txt)
1414
*/
1515

16-
#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__
16+
#if __ELF__
1717
/*
1818
* Mark the resulting object file as not requiring execution permissions on
1919
* stack memory. The absence of this section would mark the whole resulting
2020
* library as requiring an executable stack, making it impossible to
21-
* dynamically load druntime on several Linux platforms where this is
22-
* forbidden due to security policies.
21+
* dynamically load druntime on several platforms where this is forbidden
22+
* due to security policies.
2323
*/
2424
.section .note.GNU-stack,"",%progbits
2525
#endif

runtime/druntime/src/core/thread/fiber/switch_context_riscv.S

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
* Authors: Denis Feklushkin
77
*/
88

9+
#if __ELF__
10+
/*
11+
* Mark the resulting object file as not requiring execution permissions on
12+
* stack memory. The absence of this section would mark the whole resulting
13+
* library as requiring an executable stack, making it impossible to
14+
* dynamically load druntime on several platforms where this is forbidden
15+
* due to security policies.
16+
*/
17+
.section .note.GNU-stack,"",%progbits
18+
#endif
19+
20+
921
#if defined(__riscv)
1022

1123
// For save/load a register in memory, regardless of the size of machine register bit size

runtime/druntime/src/ldc/eh_asm.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
77
*/
88

9+
#if __ELF__
910
/*
1011
* Mark the resulting object file as not requiring execution
1112
* permissions on stack memory. The absence of this section would mark
1213
* the whole resulting library as requiring an executable stack,
13-
* making it impossible to dynamically load druntime on several Linux
14+
* making it impossible to dynamically load druntime on several
1415
* platforms where this is forbidden due to security policies.
1516
*/
16-
17-
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
1817
.section .note.GNU-stack,"",%progbits
1918
.previous
2019
#endif

0 commit comments

Comments
 (0)