about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-07-27 13:41:35 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-08-10 16:35:44 -0700
commit7a3fdfbf674a08b7f6fd32c9124e52924a2f9a1c (patch)
tree5553605e8d9ac7fc23cfec8f689f6c923e78abdd /src/rt
parentd03456183e85fe7bd465bbe7c8f67885a2528444 (diff)
Remove morestack support
This commit removes all morestack support from the compiler which entails:

* Segmented stacks are no longer emitted in codegen.
* We no longer build or distribute libmorestack.a
* The `stack_exhausted` lang item is no longer required

The only current use of the segmented stack support in LLVM is to detect stack
overflow. This is no longer really required, however, because we already have
guard pages for all threads and registered signal handlers watching for a
segfault on those pages (to print out a stack overflow message). Additionally,
major platforms (aka Windows) already don't use morestack.

This means that Rust is by default less likely to catch stack overflows because
if a function takes up more than one page of stack space it won't hit the guard
page. This is what the purpose of morestack was (to catch this case), but it's
better served with stack probes which have more cross platform support and no
runtime support necessary. Until LLVM supports this for all platform it looks
like morestack isn't really buying us much.

cc #16012 (still need stack probes)
Closes #26458 (a drive-by fix to help diagnostics on stack overflow)
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/arch/aarch64/macros.S11
-rw-r--r--src/rt/arch/aarch64/morestack.S39
-rw-r--r--src/rt/arch/aarch64/record_sp.S6
-rw-r--r--src/rt/arch/arm/morestack.S70
-rw-r--r--src/rt/arch/arm/record_sp.S56
-rw-r--r--src/rt/arch/armv7/morestack.S70
-rw-r--r--src/rt/arch/armv7/record_sp.S56
-rw-r--r--src/rt/arch/armv7s/morestack.S70
-rw-r--r--src/rt/arch/armv7s/record_sp.S56
-rw-r--r--src/rt/arch/i386/morestack.S143
-rw-r--r--src/rt/arch/i386/record_sp.S4
-rw-r--r--src/rt/arch/mips/morestack.S43
-rw-r--r--src/rt/arch/mips/record_sp.S40
-rw-r--r--src/rt/arch/mipsel/morestack.S43
-rw-r--r--src/rt/arch/mipsel/record_sp.S40
-rw-r--r--src/rt/arch/powerpc/morestack.S18
-rw-r--r--src/rt/arch/powerpc/record_sp.S4
-rw-r--r--src/rt/arch/x86_64/morestack.S69
-rw-r--r--src/rt/arch/x86_64/record_sp.S4
-rw-r--r--src/rt/empty.c9
20 files changed, 9 insertions, 842 deletions
diff --git a/src/rt/arch/aarch64/macros.S b/src/rt/arch/aarch64/macros.S
deleted file mode 100644
index ae42a5d2243..00000000000
--- a/src/rt/arch/aarch64/macros.S
+++ /dev/null
@@ -1,11 +0,0 @@
-.macro	func _name
-	.text
-	.align	2
-	.globl	\_name
-	.type	\_name, %function
-\_name:
-.endm
-
-.macro	endfunc _name
-	.size	\_name, .-\_name
-.endm
diff --git a/src/rt/arch/aarch64/morestack.S b/src/rt/arch/aarch64/morestack.S
deleted file mode 100644
index 8b7366ebed4..00000000000
--- a/src/rt/arch/aarch64/morestack.S
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "macros.S"
-
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-#if defined(__APPLE__)
-#define MORESTACK ___morestack
-#define STACK_EXHAUSTED _rust_stack_exhausted@plt
-#else
-#define MORESTACK __morestack
-#define STACK_EXHAUSTED rust_stack_exhausted
-#endif
-
-.global STACK_EXHAUSTED
-
-#if defined(__APPLE__)
-.private_extern MORESTACK
-#else
-.hidden MORESTACK
-#endif
-
-#if !defined(__APPLE__)
-func MORESTACK
-#endif
-
-// FIXME(AARCH64): this might not be perfectly right but works for now
-MORESTACK:
-	.cfi_startproc
-	bl STACK_EXHAUSTED
-	// the above function ensures that it never returns
-	.cfi_endproc
-
-#if !defined(__APPLE__)
-endfunc MORESTACK
-#endif
diff --git a/src/rt/arch/aarch64/record_sp.S b/src/rt/arch/aarch64/record_sp.S
deleted file mode 100644
index 115e286866e..00000000000
--- a/src/rt/arch/aarch64/record_sp.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "macros.S"
-
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S
deleted file mode 100644
index 0b9012cc2a8..00000000000
--- a/src/rt/arch/arm/morestack.S
+++ /dev/null
@@ -1,70 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-.code 32
-.arm
-#if defined(__APPLE__)
-.align 2
-#else
-.align
-#endif
-
-#if defined(__APPLE__)
-#define MORESTACK ___morestack
-#define STACK_EXHAUSTED _rust_stack_exhausted
-#else
-#define MORESTACK __morestack
-#define STACK_EXHAUSTED rust_stack_exhausted
-#endif
-
-.global STACK_EXHAUSTED
-.global MORESTACK
-
-// Unfortunately LLVM yet doesn't support emitting correct debug
-// DWARF information for non-ELF targets so to make it compile
-// on iOS all that directives are simply commented out
-#if defined(__APPLE__)
-#define UNWIND @
-#else
-#define UNWIND
-#endif
-
-#if defined(__APPLE__)
-.private_extern MORESTACK
-#else
-.hidden MORESTACK
-#endif
-
-#if !defined(__APPLE__)
-   .type MORESTACK,%function
-#endif
-
-// r4 and r5 are scratch registers for __morestack due to llvm
-// ARMFrameLowering::adjustForSegmentedStacks() implementation.
-MORESTACK:
-    UNWIND .fnstart
-
-    // Save frame pointer and return address
-    UNWIND .save {r4, r5}
-    UNWIND .save {lr}
-    UNWIND .save {r6, fp, lr}
-    push {r6, fp, lr}
-
-    UNWIND .movsp r6
-    mov r6, sp
-    UNWIND .setfp fp, sp, #4
-    add fp, sp, #4
-
-    // Save argument registers of the original function
-    push {r0, r1, r2, r3, lr}
-
-    // Create new stack
-    bl STACK_EXHAUSTED@plt
-
-    // the above function ensures that it never returns
-    UNWIND  .fnend
diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S
deleted file mode 100644
index d0e9b81b95a..00000000000
--- a/src/rt/arch/arm/record_sp.S
+++ /dev/null
@@ -1,56 +0,0 @@
-// Do not compile anything here for iOS because split stacks
-// are disabled at all and do not need any runtime support.
-//
-// See also comments in librustrt/stack.rs about why it was
-// disabled and how it could be implemented in case of need.
-#if !defined(__APPLE__)
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-.text
-.code 32
-.arm
-.align
-
-#define RECORD_SP_LIMIT record_sp_limit
-#define GET_SP_LIMIT    get_sp_limit
-
-.globl 	RECORD_SP_LIMIT
-.globl	GET_SP_LIMIT
-
-RECORD_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif // ANDROID
-
-	str r0, [r3]
-	mov pc, lr
-
-GET_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif  // __ANDROID__
-
-	ldr r0, [r3]
-	mov pc, lr
-#endif
diff --git a/src/rt/arch/armv7/morestack.S b/src/rt/arch/armv7/morestack.S
deleted file mode 100644
index 0b9012cc2a8..00000000000
--- a/src/rt/arch/armv7/morestack.S
+++ /dev/null
@@ -1,70 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-.code 32
-.arm
-#if defined(__APPLE__)
-.align 2
-#else
-.align
-#endif
-
-#if defined(__APPLE__)
-#define MORESTACK ___morestack
-#define STACK_EXHAUSTED _rust_stack_exhausted
-#else
-#define MORESTACK __morestack
-#define STACK_EXHAUSTED rust_stack_exhausted
-#endif
-
-.global STACK_EXHAUSTED
-.global MORESTACK
-
-// Unfortunately LLVM yet doesn't support emitting correct debug
-// DWARF information for non-ELF targets so to make it compile
-// on iOS all that directives are simply commented out
-#if defined(__APPLE__)
-#define UNWIND @
-#else
-#define UNWIND
-#endif
-
-#if defined(__APPLE__)
-.private_extern MORESTACK
-#else
-.hidden MORESTACK
-#endif
-
-#if !defined(__APPLE__)
-   .type MORESTACK,%function
-#endif
-
-// r4 and r5 are scratch registers for __morestack due to llvm
-// ARMFrameLowering::adjustForSegmentedStacks() implementation.
-MORESTACK:
-    UNWIND .fnstart
-
-    // Save frame pointer and return address
-    UNWIND .save {r4, r5}
-    UNWIND .save {lr}
-    UNWIND .save {r6, fp, lr}
-    push {r6, fp, lr}
-
-    UNWIND .movsp r6
-    mov r6, sp
-    UNWIND .setfp fp, sp, #4
-    add fp, sp, #4
-
-    // Save argument registers of the original function
-    push {r0, r1, r2, r3, lr}
-
-    // Create new stack
-    bl STACK_EXHAUSTED@plt
-
-    // the above function ensures that it never returns
-    UNWIND  .fnend
diff --git a/src/rt/arch/armv7/record_sp.S b/src/rt/arch/armv7/record_sp.S
deleted file mode 100644
index d0e9b81b95a..00000000000
--- a/src/rt/arch/armv7/record_sp.S
+++ /dev/null
@@ -1,56 +0,0 @@
-// Do not compile anything here for iOS because split stacks
-// are disabled at all and do not need any runtime support.
-//
-// See also comments in librustrt/stack.rs about why it was
-// disabled and how it could be implemented in case of need.
-#if !defined(__APPLE__)
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-.text
-.code 32
-.arm
-.align
-
-#define RECORD_SP_LIMIT record_sp_limit
-#define GET_SP_LIMIT    get_sp_limit
-
-.globl 	RECORD_SP_LIMIT
-.globl	GET_SP_LIMIT
-
-RECORD_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif // ANDROID
-
-	str r0, [r3]
-	mov pc, lr
-
-GET_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif  // __ANDROID__
-
-	ldr r0, [r3]
-	mov pc, lr
-#endif
diff --git a/src/rt/arch/armv7s/morestack.S b/src/rt/arch/armv7s/morestack.S
deleted file mode 100644
index 0b9012cc2a8..00000000000
--- a/src/rt/arch/armv7s/morestack.S
+++ /dev/null
@@ -1,70 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-.code 32
-.arm
-#if defined(__APPLE__)
-.align 2
-#else
-.align
-#endif
-
-#if defined(__APPLE__)
-#define MORESTACK ___morestack
-#define STACK_EXHAUSTED _rust_stack_exhausted
-#else
-#define MORESTACK __morestack
-#define STACK_EXHAUSTED rust_stack_exhausted
-#endif
-
-.global STACK_EXHAUSTED
-.global MORESTACK
-
-// Unfortunately LLVM yet doesn't support emitting correct debug
-// DWARF information for non-ELF targets so to make it compile
-// on iOS all that directives are simply commented out
-#if defined(__APPLE__)
-#define UNWIND @
-#else
-#define UNWIND
-#endif
-
-#if defined(__APPLE__)
-.private_extern MORESTACK
-#else
-.hidden MORESTACK
-#endif
-
-#if !defined(__APPLE__)
-   .type MORESTACK,%function
-#endif
-
-// r4 and r5 are scratch registers for __morestack due to llvm
-// ARMFrameLowering::adjustForSegmentedStacks() implementation.
-MORESTACK:
-    UNWIND .fnstart
-
-    // Save frame pointer and return address
-    UNWIND .save {r4, r5}
-    UNWIND .save {lr}
-    UNWIND .save {r6, fp, lr}
-    push {r6, fp, lr}
-
-    UNWIND .movsp r6
-    mov r6, sp
-    UNWIND .setfp fp, sp, #4
-    add fp, sp, #4
-
-    // Save argument registers of the original function
-    push {r0, r1, r2, r3, lr}
-
-    // Create new stack
-    bl STACK_EXHAUSTED@plt
-
-    // the above function ensures that it never returns
-    UNWIND  .fnend
diff --git a/src/rt/arch/armv7s/record_sp.S b/src/rt/arch/armv7s/record_sp.S
deleted file mode 100644
index d0e9b81b95a..00000000000
--- a/src/rt/arch/armv7s/record_sp.S
+++ /dev/null
@@ -1,56 +0,0 @@
-// Do not compile anything here for iOS because split stacks
-// are disabled at all and do not need any runtime support.
-//
-// See also comments in librustrt/stack.rs about why it was
-// disabled and how it could be implemented in case of need.
-#if !defined(__APPLE__)
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", %progbits
-#endif
-
-.text
-.code 32
-.arm
-.align
-
-#define RECORD_SP_LIMIT record_sp_limit
-#define GET_SP_LIMIT    get_sp_limit
-
-.globl 	RECORD_SP_LIMIT
-.globl	GET_SP_LIMIT
-
-RECORD_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif // ANDROID
-
-	str r0, [r3]
-	mov pc, lr
-
-GET_SP_LIMIT:
-	// First, try to read TLS address from coprocessor
-	mrc p15, #0, r3, c13, c0, #3
-	cmp r3, #0
-	// Otherwise, try to read from magic address 0xFFFF0FF0
-	mvneq r3, #0xF000
-	ldreq r3, [r3, #-15]
-
-#if __ANDROID__
-	add r3, r3, #252
-#elif __linux__
-	add r3, r3, #4
-#endif  // __ANDROID__
-
-	ldr r0, [r3]
-	mov pc, lr
-#endif
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S
deleted file mode 100644
index 98fdfdf3402..00000000000
--- a/src/rt/arch/i386/morestack.S
+++ /dev/null
@@ -1,143 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
-
-/*
-	__morestack
-
-        This function is normally used to implement stack growth using the
-        mechanism devised by Ian Lance Taylor for gccgo, described here:
-
-	http://gcc.gnu.org/wiki/SplitStacks
-
-        Each Rust function contains an LLVM-generated prologue that compares the
-        stack space required for the current function to the space remaining in
-        the current stack segment, maintained in a platform-specific TLS slot.
-        The stack limit is strategically maintained by the Rust runtime so that
-        it is always in place whenever a Rust function is running.
-
-        In Rust, however, we currently do not use __morestack for stack growth
-        purposes.  Rather each task has one large stack segment. When this
-        __morestack function is run, we interpret this as a "stack overflow"
-        event rather than an event requiring an allocation of a new stack.
-
-        In the early days, this implementation did indeed have all of the fiddly
-        bits in order to manage split stacks in the sense of always growing
-        stacks. For posterity, the implementation can be found at commit
-        c8e77d5586aed50821e0b9361b2e24c96ade816c if we ever need to refer back
-        to it.
-
-	-- The __morestack calling convention --
-
-	For reasons of efficiency the __morestack calling convention
-	is bizarre. The calling function does not attempt to align the
-	stack for the call, and on x86_64 the arguments to __morestack
-	are passed in scratch registers in order to preserve the
-	original function's arguments.
-
-	Once __morestack has switched to the new stack, instead of
-	returning, it then calls into the original function, resuming
-	execution at the instruction following the call to
-	__morestack. Thus, when the original function returns it
-	actually returns to __morestack, which then deallocates the
-	stack and returns again to the original function's caller.
-
-	-- Unwinding --
-
-	All this trickery causes hell when it comes time for the
-	unwinder to navigate it's way through this function. What
-	will happen is the original function will be unwound first
-	without any special effort, then the unwinder encounters
-	the __morestack frame, which is sitting just above a
-	tiny fraction of a frame (containing just a return pointer
-	and, on 32-bit, the arguments to __morestack).
-
-	We deal with this by claiming that little bit of stack
-	is actually part of the __morestack frame, encoded as
-	DWARF call frame instructions (CFI) by .cfi assembler
-	pseudo-ops.
-
-	One final complication (that took me a week to figure out)
-	is that OS X 10.6+ uses its own 'compact unwind info',
-	an undocumented format generated by the linker from
-	the DWARF CFI. This compact unwind info doesn't correctly
-	capture the nuance of the __morestack frame, so we need to
-	prevent the linker from attempting to convert its DWARF unwind
-	information.
-*/
-
-.text
-
-#if defined(__APPLE__)
-#define MORESTACK               ___morestack
-#define EXHAUSTED               _rust_stack_exhausted
-#else
-#if defined(__linux__) || defined(__FreeBSD__)
-#define MORESTACK               __morestack
-#define EXHAUSTED               rust_stack_exhausted@plt
-#else
-#define MORESTACK               ___morestack
-#define EXHAUSTED               _rust_stack_exhausted
-#endif
-#endif
-
-.globl MORESTACK
-
-// FIXME: What about __WIN32__?
-#if defined(__linux__) || defined(__FreeBSD__)
-	.hidden MORESTACK
-#else
-#if defined(__APPLE__)
-	.private_extern MORESTACK
-#endif
-#endif
-
-#ifdef __ELF__
-	.type MORESTACK,@function
-#endif
-
-MORESTACK:
-	.cfi_startproc
-
-	// This base pointer setup differs from most in that we are
-	// telling the unwinder to consider the Canonical Frame
-	// Address (CFA) for this frame to be the value of the stack
-	// pointer prior to entry to the original function, whereas
-	// the CFA would typically be the value of the stack
-	// pointer prior to entry to this function. This will allow
-	// the unwinder to understand how to skip the tiny partial
-	// frame that the original function created by calling
-	// __morestack.
-
-	// In practical terms, our CFA is 12 bytes greater than it
-	// would normally be, accounting for the two arguments to
-	// __morestack, and an extra return address.
-
-        // FIXME(#9854) these cfi directives don't work on windows.
-
-	pushl %ebp
-
-#if defined(__APPLE__)
-	// The pattern of the return address being saved twice to the same location
-	// tells the OS X linker that it should not attempt to convert the DWARF
-	// unwind information to the compact format.
-	.cfi_offset %eip, -4
-	.cfi_offset %eip, -4
-#endif
-
-	// The CFA is 20 bytes above the register that it is
-	// associated with for this frame (which will be %ebp)
-	.cfi_def_cfa_offset 20
-	// %ebp is -20 bytes from the CFA
-	.cfi_offset %ebp, -20
-	movl %esp, %ebp
-	// Calculate the CFA as an offset from %ebp
-	.cfi_def_cfa_register %ebp
-
-        // re-align the stack
-        subl $12,%esp
-        call EXHAUSTED
-        // the exhaustion function guarantees that it can't return
-
-	.cfi_endproc
diff --git a/src/rt/arch/i386/record_sp.S b/src/rt/arch/i386/record_sp.S
deleted file mode 100644
index 12d9a2b6456..00000000000
--- a/src/rt/arch/i386/record_sp.S
+++ /dev/null
@@ -1,4 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
diff --git a/src/rt/arch/mips/morestack.S b/src/rt/arch/mips/morestack.S
deleted file mode 100644
index 266933df8c5..00000000000
--- a/src/rt/arch/mips/morestack.S
+++ /dev/null
@@ -1,43 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section        .note.GNU-stack, "", @progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-
-.globl rust_stack_exhausted
-.globl __morestack
-
-.hidden __morestack
-
-.cfi_startproc
-.set nomips16
-.ent __morestack
-__morestack:
-        .set noreorder
-        .set nomacro
-
-        addiu $29, $29, -4
-        sw $30, 0($29)
-
-        // 16 = 4 (current) + 12 (previous)
-        .cfi_def_cfa_offset 16
-        .cfi_offset 31, -4
-        .cfi_offset 30, -16
-
-        move $30, $29
-        .cfi_def_cfa_register 30
-
-        // O32 ABI always reserves 16 bytes for arguments
-        addiu $29, $29, -16
-
-        lw $25, %call16(rust_stack_exhausted)($28)
-        jalr $25
-        nop
-
-        // the above function make sure that we never get here
-
-.end __morestack
-.cfi_endproc
diff --git a/src/rt/arch/mips/record_sp.S b/src/rt/arch/mips/record_sp.S
deleted file mode 100644
index a6dfa04edbb..00000000000
--- a/src/rt/arch/mips/record_sp.S
+++ /dev/null
@@ -1,40 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
-
-.text
-
-.globl record_sp_limit
-.align 2
-.set nomips16
-.ent record_sp_limit
-record_sp_limit:
-        .set noreorder
-        .set nomacro
-        .set push
-        .set mips32r2
-        rdhwr $3, $29
-        .set pop
-        addiu $3, $3, -0x7004
-        sw $4, 0($3)
-        jr $31
-        nop
-.end record_sp_limit
-
-.globl get_sp_limit
-.align 2
-.set nomips16
-.ent get_sp_limit
-get_sp_limit:
-        .set noreorder
-        .set nomacro
-        .set push
-        .set mips32r2
-        rdhwr $3, $29
-        .set pop
-        addiu $3, $3, -0x7004
-        lw $2, 0($3)
-        jr $31
-        nop
-.end get_sp_limit
diff --git a/src/rt/arch/mipsel/morestack.S b/src/rt/arch/mipsel/morestack.S
deleted file mode 100644
index 266933df8c5..00000000000
--- a/src/rt/arch/mipsel/morestack.S
+++ /dev/null
@@ -1,43 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section        .note.GNU-stack, "", @progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-
-.globl rust_stack_exhausted
-.globl __morestack
-
-.hidden __morestack
-
-.cfi_startproc
-.set nomips16
-.ent __morestack
-__morestack:
-        .set noreorder
-        .set nomacro
-
-        addiu $29, $29, -4
-        sw $30, 0($29)
-
-        // 16 = 4 (current) + 12 (previous)
-        .cfi_def_cfa_offset 16
-        .cfi_offset 31, -4
-        .cfi_offset 30, -16
-
-        move $30, $29
-        .cfi_def_cfa_register 30
-
-        // O32 ABI always reserves 16 bytes for arguments
-        addiu $29, $29, -16
-
-        lw $25, %call16(rust_stack_exhausted)($28)
-        jalr $25
-        nop
-
-        // the above function make sure that we never get here
-
-.end __morestack
-.cfi_endproc
diff --git a/src/rt/arch/mipsel/record_sp.S b/src/rt/arch/mipsel/record_sp.S
deleted file mode 100644
index a6dfa04edbb..00000000000
--- a/src/rt/arch/mipsel/record_sp.S
+++ /dev/null
@@ -1,40 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
-
-.text
-
-.globl record_sp_limit
-.align 2
-.set nomips16
-.ent record_sp_limit
-record_sp_limit:
-        .set noreorder
-        .set nomacro
-        .set push
-        .set mips32r2
-        rdhwr $3, $29
-        .set pop
-        addiu $3, $3, -0x7004
-        sw $4, 0($3)
-        jr $31
-        nop
-.end record_sp_limit
-
-.globl get_sp_limit
-.align 2
-.set nomips16
-.ent get_sp_limit
-get_sp_limit:
-        .set noreorder
-        .set nomacro
-        .set push
-        .set mips32r2
-        rdhwr $3, $29
-        .set pop
-        addiu $3, $3, -0x7004
-        lw $2, 0($3)
-        jr $31
-        nop
-.end get_sp_limit
diff --git a/src/rt/arch/powerpc/morestack.S b/src/rt/arch/powerpc/morestack.S
deleted file mode 100644
index 2502ac1eb48..00000000000
--- a/src/rt/arch/powerpc/morestack.S
+++ /dev/null
@@ -1,18 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section       .note.GNU-stack, "", %progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.global rust_stack_exhausted
-
-.hidden __morestack
-
-// FIXME(POWERPC): this might not be perfectly right but works for now
-__morestack:
-       .cfi_startproc
-       bl rust_stack_exhausted
-       // the above function ensures that it never returns
-       .cfi_endproc
-.end  __morestack
diff --git a/src/rt/arch/powerpc/record_sp.S b/src/rt/arch/powerpc/record_sp.S
deleted file mode 100644
index e93a69a711b..00000000000
--- a/src/rt/arch/powerpc/record_sp.S
+++ /dev/null
@@ -1,4 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section       .note.GNU-stack, "", %progbits
-#endif
diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S
deleted file mode 100644
index cf2b9b9f717..00000000000
--- a/src/rt/arch/x86_64/morestack.S
+++ /dev/null
@@ -1,69 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
-
-/* See i386/morestack.S for the lengthy, general explanation. */
-
-.text
-
-#if defined(__APPLE__)
-#define MORESTACK               ___morestack
-#else
-#define MORESTACK               __morestack
-#endif
-
-#if defined(__APPLE__)
-#define EXHAUSTED               _rust_stack_exhausted
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__Bitrig__)
-#define EXHAUSTED               rust_stack_exhausted@PLT
-#else
-#define EXHAUSTED               rust_stack_exhausted
-#endif
-
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__Bitrig__)
-	.hidden MORESTACK
-#else
-#if defined(__APPLE__)
-	.private_extern MORESTACK
-#endif
-#endif
-
-#ifdef __ELF__
-	.type MORESTACK,@function
-#endif
-
-.globl MORESTACK
-MORESTACK:
-	.cfi_startproc
-
-	pushq %rbp
-	// The CFA is 24 bytes above the register that it will
-	// be associated with for this frame (%rbp). That is 8
-	// bytes greater than a normal frame, to allow the unwinder
-	// to skip the partial frame of the original function.
-	.cfi_def_cfa_offset 24
-
-#if defined(__APPLE__)
-	// The pattern of the return address being saved twice to the same location
-	// tells the OS X linker that it should not attempt to convert the DWARF
-	// unwind information to the compact format.
-	.cfi_offset %rip, -8
-	.cfi_offset %rip, -8
-#endif
-
-	// %rbp is -24 bytes from the CFA
-	.cfi_offset %rbp, -24
-	movq %rsp, %rbp
-	// Calculate the CFA as on offset from %ebp
-	.cfi_def_cfa_register %rbp
-
-        // re-align the stack
-        subq $8, %rsp
-
-        // kill this program
-        call EXHAUSTED
-
-        // the exhaustion function guarantees that it can't return
-
-	.cfi_endproc
diff --git a/src/rt/arch/x86_64/record_sp.S b/src/rt/arch/x86_64/record_sp.S
deleted file mode 100644
index 12d9a2b6456..00000000000
--- a/src/rt/arch/x86_64/record_sp.S
+++ /dev/null
@@ -1,4 +0,0 @@
-// Mark stack as non-executable
-#if defined(__linux__) && defined(__ELF__)
-.section	.note.GNU-stack, "", @progbits
-#endif
diff --git a/src/rt/empty.c b/src/rt/empty.c
new file mode 100644
index 00000000000..6a54ed322de
--- /dev/null
+++ b/src/rt/empty.c
@@ -0,0 +1,9 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.