]> git.lizzy.rs Git - rust.git/blob - src/rt/arch/x86_64/morestack.S
Port Rust to DragonFlyBSD
[rust.git] / src / rt / arch / x86_64 / 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
10 #if defined(__APPLE__)
11 #define MORESTACK               ___morestack
12 #else
13 #define MORESTACK               __morestack
14 #endif
15
16 #if defined(__APPLE__)
17 #define EXHAUSTED               _rust_stack_exhausted
18 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
19 #define EXHAUSTED               rust_stack_exhausted@PLT
20 #else
21 #define EXHAUSTED               rust_stack_exhausted
22 #endif
23
24 #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
25         .hidden MORESTACK
26 #else
27 #if defined(__APPLE__)
28         .private_extern MORESTACK
29 #endif
30 #endif
31
32 #ifdef __ELF__
33         .type MORESTACK,@function
34 #endif
35
36 .globl MORESTACK
37 MORESTACK:
38         .cfi_startproc
39
40         pushq %rbp
41         // The CFA is 24 bytes above the register that it will
42         // be associated with for this frame (%rbp). That is 8
43         // bytes greater than a normal frame, to allow the unwinder
44         // to skip the partial frame of the original function.
45         .cfi_def_cfa_offset 24
46
47 #if defined(__APPLE__)
48         // The pattern of the return address being saved twice to the same location
49         // tells the OS X linker that it should not attempt to convert the DWARF
50         // unwind information to the compact format.
51         .cfi_offset %rip, -8
52         .cfi_offset %rip, -8
53 #endif
54
55         // %rbp is -24 bytes from the CFA
56         .cfi_offset %rbp, -24
57         movq %rsp, %rbp
58         // Calculate the CFA as on offset from %ebp
59         .cfi_def_cfa_register %rbp
60
61         // re-align the stack
62         subq $8, %rsp
63
64         // kill this program
65         call EXHAUSTED
66
67         // the exhaustion function guarantees that it can't return
68
69         .cfi_endproc