about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorValerii Hiora <valerii.hiora@gmail.com>2015-01-07 12:24:18 +0200
committerValerii Hiora <valerii.hiora@gmail.com>2015-01-09 18:38:30 +0200
commita945f288ffc3c4db6ab1539e6de7df07d898cdb5 (patch)
treeab3fb6957226ac31ae67211738db75ea8c15ff82 /src/rt
parentea045d2055638a6cf66e4bd675c6f7deec7a8d8b (diff)
downloadrust-a945f288ffc3c4db6ab1539e6de7df07d898cdb5.tar.gz
rust-a945f288ffc3c4db6ab1539e6de7df07d898cdb5.zip
iOS: makefiles and runtime for new archs
Diffstat (limited to 'src/rt')
-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
4 files changed, 252 insertions, 0 deletions
diff --git a/src/rt/arch/armv7/morestack.S b/src/rt/arch/armv7/morestack.S
new file mode 100644
index 00000000000..0b9012cc2a8
--- /dev/null
+++ b/src/rt/arch/armv7/morestack.S
@@ -0,0 +1,70 @@
+// 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
new file mode 100644
index 00000000000..d0e9b81b95a
--- /dev/null
+++ b/src/rt/arch/armv7/record_sp.S
@@ -0,0 +1,56 @@
+// 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
new file mode 100644
index 00000000000..0b9012cc2a8
--- /dev/null
+++ b/src/rt/arch/armv7s/morestack.S
@@ -0,0 +1,70 @@
+// 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
new file mode 100644
index 00000000000..d0e9b81b95a
--- /dev/null
+++ b/src/rt/arch/armv7s/record_sp.S
@@ -0,0 +1,56 @@
+// 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