about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-31 17:06:42 -0700
committerbors <bors@rust-lang.org>2013-03-31 17:06:42 -0700
commitb9c7ee5cfa566b07c5b4099de7cea232e7153e59 (patch)
tree0e43afa9f9cf08d3536958fdafbb792fb30fa633 /src
parentf336afd45990f3799f0fa5667a992c2c06789fc3 (diff)
parentc0be7df5de2d5b5137f66743a428d1843b98ba9b (diff)
auto merge of #5647 : thestinger/rust/execstack, r=brson
Closes #5643
Diffstat (limited to 'src')
-rw-r--r--src/rt/arch/arm/_context.S13
-rw-r--r--src/rt/arch/arm/ccall.S6
-rw-r--r--src/rt/arch/arm/morestack.S5
-rw-r--r--src/rt/arch/arm/record_sp.S11
-rw-r--r--src/rt/arch/i386/_context.S5
-rw-r--r--src/rt/arch/i386/ccall.S5
-rw-r--r--src/rt/arch/i386/morestack.S11
-rw-r--r--src/rt/arch/i386/record_sp.S4
-rw-r--r--src/rt/arch/mips/_context.S5
-rw-r--r--src/rt/arch/mips/ccall.S5
-rw-r--r--src/rt/arch/mips/record_sp.S5
-rw-r--r--src/rt/arch/x86_64/_context.S15
-rw-r--r--src/rt/arch/x86_64/ccall.S7
-rw-r--r--src/rt/arch/x86_64/morestack.S9
-rw-r--r--src/rt/arch/x86_64/record_sp.S4
15 files changed, 91 insertions, 19 deletions
diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S
index 8d370c2d64e..b29575aada9 100644
--- a/src/rt/arch/arm/_context.S
+++ b/src/rt/arch/arm/_context.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 .code 32
 .arm
@@ -17,12 +22,12 @@ swap_registers:
 	str r10, [r0, #40]
 	str r11, [r0, #44]
 	str r12, [r0, #48]
-	str sp, [r0, #52] 
+	str sp, [r0, #52]
 	str lr, [r0, #56]
 
 	mrs r2, cpsr
 	str r2, [r0, #64]
-	
+
 
 	ldr r0, [r1, #0]
 	ldr r3, [r1, #12]
@@ -35,10 +40,10 @@ swap_registers:
 	ldr r10, [r1, #40]
 	ldr r11, [r1, #44]
 	ldr r12, [r1, #48]
-	
+
 	ldr sp, [r1, #52]
 	ldr lr, [r1, #56]
-	 
+
 	ldr r2, [r1, #64]
 	msr cpsr_cxsf, r2
 
diff --git a/src/rt/arch/arm/ccall.S b/src/rt/arch/arm/ccall.S
index 345e6462d07..52806d67837 100644
--- a/src/rt/arch/arm/ccall.S
+++ b/src/rt/arch/arm/ccall.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 .code 32
 .arm
@@ -19,4 +24,3 @@ __morestack:
 	pop {r4, fp, lr}
 	mov pc, lr
 	.fnend
-
diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S
index bc1c0c23025..ccb23037f79 100644
--- a/src/rt/arch/arm/morestack.S
+++ b/src/rt/arch/arm/morestack.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 .code 32
 .arm
diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S
index 193104d53b1..528359420e6 100644
--- a/src/rt/arch/arm/record_sp.S
+++ b/src/rt/arch/arm/record_sp.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 .code 32
 .arm
@@ -45,11 +50,12 @@ get_sp_limit:
 get_sp:
 	mov r0, sp
 	mov pc, lr
-	
+
 .data
 my_cpu:	.long	0
 .global my_array
-my_array:	
+my_array:
+	.long	0
 	.long	0
 	.long	0
 	.long	0
@@ -57,5 +63,4 @@ my_array:
 	.long	0
 	.long	0
 	.long	0
-	.long	0	
 .end
diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S
index d8b7281e72b..d2643d07c3d 100644
--- a/src/rt/arch/i386/_context.S
+++ b/src/rt/arch/i386/_context.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
         .text
 
 /*
diff --git a/src/rt/arch/i386/ccall.S b/src/rt/arch/i386/ccall.S
index c04c3e01c7e..e47d51bbdb7 100644
--- a/src/rt/arch/i386/ccall.S
+++ b/src/rt/arch/i386/ccall.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 /*
 	The function for switching to the C stack.  It is called
 	__morestack because gdb allows any frame with that name to
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S
index 7f2205b573a..e8a9c1312ed 100644
--- a/src/rt/arch/i386/morestack.S
+++ b/src/rt/arch/i386/morestack.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 /*
 	__morestack
 
@@ -218,11 +223,11 @@ MORESTACK:
 .L$bail:
 	movl 32(%esp),%eax
 	inc %eax
-	
+
 	addl $44, %esp
 	popl %ebp
 	addl $4+8,%esp
-	
+
 	jmpl *%eax
 
 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
@@ -241,7 +246,7 @@ L_rust_get_task$stub:
 L_upcall_new_stack$stub:
 	.indirect_symbol _upcall_new_stack
 	.ascii	 "\364\364\364\364\364"
-	
+
 L_upcall_del_stack$stub:
 	.indirect_symbol _upcall_del_stack
 	.ascii	 "\364\364\364\364\364"
diff --git a/src/rt/arch/i386/record_sp.S b/src/rt/arch/i386/record_sp.S
index e69de29bb2d..12d9a2b6456 100644
--- a/src/rt/arch/i386/record_sp.S
+++ b/src/rt/arch/i386/record_sp.S
@@ -0,0 +1,4 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
diff --git a/src/rt/arch/mips/_context.S b/src/rt/arch/mips/_context.S
index 614cf686817..c926a03798d 100644
--- a/src/rt/arch/mips/_context.S
+++ b/src/rt/arch/mips/_context.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 .globl swap_registers
 .align 2
diff --git a/src/rt/arch/mips/ccall.S b/src/rt/arch/mips/ccall.S
index 522714a8807..f41d8e721f6 100644
--- a/src/rt/arch/mips/ccall.S
+++ b/src/rt/arch/mips/ccall.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 
 .globl __morestack
diff --git a/src/rt/arch/mips/record_sp.S b/src/rt/arch/mips/record_sp.S
index 6b782fc4629..dd4d2f39375 100644
--- a/src/rt/arch/mips/record_sp.S
+++ b/src/rt/arch/mips/record_sp.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 .text
 
 .globl record_sp_limit
diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S
index 1f9ae1c83c5..bedd6855467 100644
--- a/src/rt/arch/x86_64/_context.S
+++ b/src/rt/arch/x86_64/_context.S
@@ -1,7 +1,12 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 #include "regs.h"
 #define ARG0 RUSTRT_ARG0_S
 #define ARG1 RUSTRT_ARG1_S
-        
+
         .text
 
 /*
@@ -11,7 +16,7 @@ and Microsoft discussion at
 http://msdn.microsoft.com/en-US/library/9z1stfyw%28v=VS.80%29.aspx.
 
 BOTH CALLING CONVENTIONS
-        
+
 Callee save registers:
 	R12--R15, RDI, RSI, RBX, RBP, RSP
         XMM0--XMM5
@@ -30,7 +35,7 @@ User flags have no specified role and are not preserved
         across calls, with the exception of DF in %rFLAGS,
         which must be clear (set to "forward" direction)
         on function entry and return.
-        
+
 MICROSOFT CALLING CONVENTIONS
 
 Return value: RAX
@@ -39,7 +44,7 @@ First four arguments:
         RCX, RDX, R8, R9
         XMM0, XMM1, XMM2, XMM3
 */
-	
+
 /*
         Stores current registers into arg0/RCX and restores
         registers found in arg1/RDX. This is used by our
@@ -47,7 +52,7 @@ First four arguments:
         registers and the register used for the first argument.
         Volatile registers in general ought to be saved by the caller
         anyhow.
-*/	
+*/
 
 #if defined(__APPLE__) || defined(_WIN32)
 #define SWAP_REGISTERS _swap_registers
diff --git a/src/rt/arch/x86_64/ccall.S b/src/rt/arch/x86_64/ccall.S
index 42415e84a52..d4bc37fee95 100644
--- a/src/rt/arch/x86_64/ccall.S
+++ b/src/rt/arch/x86_64/ccall.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 /*
 	The function for switching to the C stack.  It is called
 	__morestack because gdb allows any frame with that name to
@@ -10,7 +15,7 @@
 #define ARG0 RUSTRT_ARG0_S
 #define ARG1 RUSTRT_ARG1_S
 #define ARG2 RUSTRT_ARG2_S
-        
+
         .text
 
 #if defined(__APPLE__) || defined(_WIN32)
diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S
index 4acb50497d9..e4dfc033bf4 100644
--- a/src/rt/arch/x86_64/morestack.S
+++ b/src/rt/arch/x86_64/morestack.S
@@ -1,3 +1,8 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif
+
 /*
 	__morestack
 
@@ -78,7 +83,7 @@ MORESTACK:
 	movq %r11, %rdx // Size of stack arguments
 	movq %rax, %rsi // Address of stack arguments
 	movq %r10, %rdi // The amount of stack needed
-        
+
 #ifdef __APPLE__
 	call UPCALL_NEW_STACK
 #endif
@@ -132,7 +137,7 @@ MORESTACK:
 	popq %rax // Restore the return value
 	popq %rbp
 	ret
-	
+
 	.cfi_endproc
 
 #else
diff --git a/src/rt/arch/x86_64/record_sp.S b/src/rt/arch/x86_64/record_sp.S
index e69de29bb2d..12d9a2b6456 100644
--- a/src/rt/arch/x86_64/record_sp.S
+++ b/src/rt/arch/x86_64/record_sp.S
@@ -0,0 +1,4 @@
+// Mark stack as non-executable
+#if defined(__linux__) && defined(__ELF__)
+.section	.note.GNU-stack, "", @progbits
+#endif