]> git.lizzy.rs Git - rust.git/blob - src/rt/arch/arm/morestack.S
Auto merge of #27529 - dotdash:c_u8, r=eddyb
[rust.git] / src / rt / arch / arm / morestack.S
1 // Mark stack as non-executable
2 #if defined(__linux__) && defined(__ELF__)
3 .section        .note.GNU-stack, "", %progbits
4 #endif
5
6 /* See i386/morestack.S for the lengthy, general explanation. */
7
8 .text
9 .code 32
10 .arm
11 #if defined(__APPLE__)
12 .align 2
13 #else
14 .align
15 #endif
16
17 #if defined(__APPLE__)
18 #define MORESTACK ___morestack
19 #define STACK_EXHAUSTED _rust_stack_exhausted
20 #else
21 #define MORESTACK __morestack
22 #define STACK_EXHAUSTED rust_stack_exhausted
23 #endif
24
25 .global STACK_EXHAUSTED
26 .global MORESTACK
27
28 // Unfortunately LLVM yet doesn't support emitting correct debug
29 // DWARF information for non-ELF targets so to make it compile
30 // on iOS all that directives are simply commented out
31 #if defined(__APPLE__)
32 #define UNWIND @
33 #else
34 #define UNWIND
35 #endif
36
37 #if defined(__APPLE__)
38 .private_extern MORESTACK
39 #else
40 .hidden MORESTACK
41 #endif
42
43 #if !defined(__APPLE__)
44    .type MORESTACK,%function
45 #endif
46
47 // r4 and r5 are scratch registers for __morestack due to llvm
48 // ARMFrameLowering::adjustForSegmentedStacks() implementation.
49 MORESTACK:
50     UNWIND .fnstart
51
52     // Save frame pointer and return address
53     UNWIND .save {r4, r5}
54     UNWIND .save {lr}
55     UNWIND .save {r6, fp, lr}
56     push {r6, fp, lr}
57
58     UNWIND .movsp r6
59     mov r6, sp
60     UNWIND .setfp fp, sp, #4
61     add fp, sp, #4
62
63     // Save argument registers of the original function
64     push {r0, r1, r2, r3, lr}
65
66     // Create new stack
67     bl STACK_EXHAUSTED@plt
68
69     // the above function ensures that it never returns
70     UNWIND  .fnend