Skip to content

Commit b9c7ee5

Browse files
committed
auto merge of #5647 : thestinger/rust/execstack, r=brson
Closes #5643
2 parents f336afd + c0be7df commit b9c7ee5

File tree

16 files changed

+94
-24
lines changed

16 files changed

+94
-24
lines changed

mk/platform.mk

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ ifdef CFG_VALGRIND
6161
endif
6262

6363
ifneq ($(findstring linux,$(CFG_OSTYPE)),)
64-
# -znoexecstack is here because librt is for some reason being created
65-
# with executable stack and Fedora (or SELinux) doesn't like that (#798)
6664
ifdef CFG_PERF
6765
ifneq ($(CFG_PERF_WITH_LOGFD),)
6866
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3 --log-fd 2
@@ -126,7 +124,7 @@ CFG_GCCISH_CXXFLAGS_x86_64-unknown-linux-gnu := -fno-rtti
126124
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-linux-gnu := -shared -fPIC -ldl -lpthread -lrt -g -m64
127125
CFG_GCCISH_DEF_FLAG_x86_64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
128126
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-whole-archive
129-
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack
127+
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive
130128
CFG_DEF_SUFFIX_x86_64-unknown-linux-gnu := .linux.def
131129
CFG_INSTALL_NAME_x86_64-unknown-linux-gnu =
132130
CFG_LIBUV_LINK_FLAGS_x86_64-unknown-linux-gnu =
@@ -152,7 +150,7 @@ CFG_GCCISH_CXXFLAGS_i686-unknown-linux-gnu := -fno-rtti
152150
CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-gnu := -shared -fPIC -ldl -lpthread -lrt -g -m32
153151
CFG_GCCISH_DEF_FLAG_i686-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
154152
CFG_GCCISH_PRE_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-whole-archive
155-
CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack
153+
CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive
156154
CFG_DEF_SUFFIX_i686-unknown-linux-gnu := .linux.def
157155
CFG_INSTALL_NAME_i686-unknown-linux-gnu =
158156
CFG_LIBUV_LINK_FLAGS_i686-unknown-linux-gnu =
@@ -228,7 +226,7 @@ CFG_GCCISH_CXXFLAGS_arm-linux-androideabi := -fno-rtti
228226
CFG_GCCISH_LINK_FLAGS_arm-linux-androideabi := -shared -fPIC -ldl -g -lm -lsupc++ -lgnustl_shared
229227
CFG_GCCISH_DEF_FLAG_arm-linux-androideabi := -Wl,--export-dynamic,--dynamic-list=
230228
CFG_GCCISH_PRE_LIB_FLAGS_arm-linux-androideabi := -Wl,-whole-archive
231-
CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive -Wl,-znoexecstack
229+
CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive
232230
CFG_DEF_SUFFIX_arm-linux-androideabi := .android.def
233231
CFG_INSTALL_NAME_arm-linux-androideabi =
234232
CFG_LIBUV_LINK_FLAGS_arm-linux-androideabi =

src/rt/arch/arm/_context.S

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27
.code 32
38
.arm
@@ -17,12 +22,12 @@ swap_registers:
1722
str r10, [r0, #40]
1823
str r11, [r0, #44]
1924
str r12, [r0, #48]
20-
str sp, [r0, #52]
25+
str sp, [r0, #52]
2126
str lr, [r0, #56]
2227

2328
mrs r2, cpsr
2429
str r2, [r0, #64]
25-
30+
2631

2732
ldr r0, [r1, #0]
2833
ldr r3, [r1, #12]
@@ -35,10 +40,10 @@ swap_registers:
3540
ldr r10, [r1, #40]
3641
ldr r11, [r1, #44]
3742
ldr r12, [r1, #48]
38-
43+
3944
ldr sp, [r1, #52]
4045
ldr lr, [r1, #56]
41-
46+
4247
ldr r2, [r1, #64]
4348
msr cpsr_cxsf, r2
4449

src/rt/arch/arm/ccall.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27
.code 32
38
.arm
@@ -19,4 +24,3 @@ __morestack:
1924
pop {r4, fp, lr}
2025
mov pc, lr
2126
.fnend
22-

src/rt/arch/arm/morestack.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27
.code 32
38
.arm

src/rt/arch/arm/record_sp.S

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27
.code 32
38
.arm
@@ -45,17 +50,17 @@ get_sp_limit:
4550
get_sp:
4651
mov r0, sp
4752
mov pc, lr
48-
53+
4954
.data
5055
my_cpu: .long 0
5156
.global my_array
52-
my_array:
57+
my_array:
58+
.long 0
5359
.long 0
5460
.long 0
5561
.long 0
5662
.long 0
5763
.long 0
5864
.long 0
5965
.long 0
60-
.long 0
6166
.end

src/rt/arch/i386/_context.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27

38
/*

src/rt/arch/i386/ccall.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
/*
27
The function for switching to the C stack. It is called
38
__morestack because gdb allows any frame with that name to

src/rt/arch/i386/morestack.S

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
/*
27
__morestack
38
@@ -218,11 +223,11 @@ MORESTACK:
218223
.L$bail:
219224
movl 32(%esp),%eax
220225
inc %eax
221-
226+
222227
addl $44, %esp
223228
popl %ebp
224229
addl $4+8,%esp
225-
230+
226231
jmpl *%eax
227232

228233
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
@@ -241,7 +246,7 @@ L_rust_get_task$stub:
241246
L_upcall_new_stack$stub:
242247
.indirect_symbol _upcall_new_stack
243248
.ascii "\364\364\364\364\364"
244-
249+
245250
L_upcall_del_stack$stub:
246251
.indirect_symbol _upcall_del_stack
247252
.ascii "\364\364\364\364\364"

src/rt/arch/i386/record_sp.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif

src/rt/arch/mips/_context.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Mark stack as non-executable
2+
#if defined(__linux__) && defined(__ELF__)
3+
.section .note.GNU-stack, "", @progbits
4+
#endif
5+
16
.text
27
.globl swap_registers
38
.align 2

0 commit comments

Comments
 (0)