diff options
| author | Valerii Hiora <valerii.hiora@gmail.com> | 2014-05-05 10:08:34 +0300 |
|---|---|---|
| committer | Valerii Hiora <valerii.hiora@gmail.com> | 2014-06-12 20:24:08 +0300 |
| commit | d730ae2fb0c455775fb1962454537c79e54f817e (patch) | |
| tree | c8c6c744b50b0e2de0b444807cfbaaaec124bac1 /src/rt/arch | |
| parent | 9e90a5e72c760cee268b714aced54ed30d04fa3c (diff) | |
Runtime support for arm on iOS
Diffstat (limited to 'src/rt/arch')
| -rw-r--r-- | src/rt/arch/arm/_context.S | 24 | ||||
| -rw-r--r-- | src/rt/arch/arm/morestack.S | 62 | ||||
| -rw-r--r-- | src/rt/arch/arm/record_sp.S | 22 |
3 files changed, 74 insertions, 34 deletions
diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S index fb6db57414a..38fc4827f58 100644 --- a/src/rt/arch/arm/_context.S +++ b/src/rt/arch/arm/_context.S @@ -12,8 +12,16 @@ .align #endif -.globl rust_swap_registers -rust_swap_registers: +#if defined(__APPLE__) + #define SWAP_REGISTERS _rust_swap_registers + #define BOOTSTRAP_TASK _rust_bootstrap_green_task +#else + #define SWAP_REGISTERS rust_swap_registers + #define BOOTSTRAP_TASK rust_bootstrap_green_task +#endif + +.globl SWAP_REGISTERS +SWAP_REGISTERS: str r0, [r0, #0] str r3, [r0, #12] str r4, [r0, #16] @@ -53,9 +61,9 @@ rust_swap_registers: mov pc, lr // For reasons of this existence, see the comments in x86_64/_context.S -.globl rust_bootstrap_green_task -rust_bootstrap_green_task: - mov r0, r0 - mov r1, r3 - mov r2, r4 - mov pc, r5 +.globl BOOTSTRAP_TASK +BOOTSTRAP_TASK: + mov r0, r0 + mov r1, r3 + mov r2, r4 + mov pc, r5 diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S index 219f0962d77..0b9012cc2a8 100644 --- a/src/rt/arch/arm/morestack.S +++ b/src/rt/arch/arm/morestack.S @@ -8,33 +8,63 @@ .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 -.global rust_stack_exhausted -.global __morestack -.hidden __morestack +#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. - .type __morestack,%function -__morestack: - .fnstart - // Save frame pointer and return address - .save {r4, r5} - .save {lr} - .save {r6, fp, lr} +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} - .movsp r6 - mov r6, sp - .setfp fp, sp, #4 - add fp, sp, #4 + 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 rust_stack_exhausted@plt + bl STACK_EXHAUSTED@plt // the above function ensures that it never returns - .fnend + UNWIND .fnend diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index cce14ed5a3e..94cfcff039e 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -1,3 +1,5 @@ +// Do not compile anything here for iOS +#if !defined(__APPLE__) // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack, "", %progbits @@ -6,16 +8,15 @@ .text .code 32 .arm -#if defined(__APPLE__) -.align 2 -#else .align -#endif -.globl record_sp_limit -.globl get_sp_limit +#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: +RECORD_SP_LIMIT: // First, try to read TLS address from coprocessor mrc p15, #0, r3, c13, c0, #3 cmp r3, #0 @@ -27,12 +28,12 @@ record_sp_limit: add r3, r3, #252 #elif __linux__ add r3, r3, #4 -#endif +#endif // ANDROID str r0, [r3] mov pc, lr -get_sp_limit: +GET_SP_LIMIT: // First, try to read TLS address from coprocessor mrc p15, #0, r3, c13, c0, #3 cmp r3, #0 @@ -44,7 +45,8 @@ get_sp_limit: add r3, r3, #252 #elif __linux__ add r3, r3, #4 -#endif +#endif // __ANDROID__ ldr r0, [r3] mov pc, lr +#endif |
