summary refs log tree commit diff
path: root/src/rt/arch/arm/morestack.S
blob: 219f0962d771c000edd75e7f90604b171b55af39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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
.align

.global rust_stack_exhausted
.global __morestack
.hidden __morestack

// 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}
    push {r6, fp, lr}

	.movsp r6
	mov r6, sp
	.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

    // the above function ensures that it never returns
    .fnend