]> git.lizzy.rs Git - rust.git/blob - src/rt/arch/armv7s/record_sp.S
Auto merge of #27529 - dotdash:c_u8, r=eddyb
[rust.git] / src / rt / arch / armv7s / record_sp.S
1 // Do not compile anything here for iOS because split stacks
2 // are disabled at all and do not need any runtime support.
3 //
4 // See also comments in librustrt/stack.rs about why it was
5 // disabled and how it could be implemented in case of need.
6 #if !defined(__APPLE__)
7 // Mark stack as non-executable
8 #if defined(__linux__) && defined(__ELF__)
9 .section        .note.GNU-stack, "", %progbits
10 #endif
11
12 .text
13 .code 32
14 .arm
15 .align
16
17 #define RECORD_SP_LIMIT record_sp_limit
18 #define GET_SP_LIMIT    get_sp_limit
19
20 .globl  RECORD_SP_LIMIT
21 .globl  GET_SP_LIMIT
22
23 RECORD_SP_LIMIT:
24         // First, try to read TLS address from coprocessor
25         mrc p15, #0, r3, c13, c0, #3
26         cmp r3, #0
27         // Otherwise, try to read from magic address 0xFFFF0FF0
28         mvneq r3, #0xF000
29         ldreq r3, [r3, #-15]
30
31 #if __ANDROID__
32         add r3, r3, #252
33 #elif __linux__
34         add r3, r3, #4
35 #endif // ANDROID
36
37         str r0, [r3]
38         mov pc, lr
39
40 GET_SP_LIMIT:
41         // First, try to read TLS address from coprocessor
42         mrc p15, #0, r3, c13, c0, #3
43         cmp r3, #0
44         // Otherwise, try to read from magic address 0xFFFF0FF0
45         mvneq r3, #0xF000
46         ldreq r3, [r3, #-15]
47
48 #if __ANDROID__
49         add r3, r3, #252
50 #elif __linux__
51         add r3, r3, #4
52 #endif  // __ANDROID__
53
54         ldr r0, [r3]
55         mov pc, lr
56 #endif