File: Thunk.S

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (50 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (3)
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
41
42
43
44
45
46
47
48
49
50
#include "Utils/Platform.h"
	.text

	.globl posixResumeExceptionThunk
	.type posixResumeExceptionThunk, @function
	.align 4

posixResumeExceptionThunk:

#if defined(X64)
	# Save registers we need. Note: We don't really need to save anything except for what
	# we need later on.
	pushq %rdx
	pushq $0

	# Call the resumeexception function. Second parameter is pointer to topmost element
	# on the stack so that we can load our stack pointer later on.
	movq %rax, %rdi
	movq %rsp, %rsi

	call *posixResumeException@GOTPCREL(%rip)

	# Restore and jump.
	popq %rcx
	popq %rdx

	# Update stack pointer and continue!
	mov %rcx, %rsp
	jmp *%rdx

#elif defined(ARM64)

	# Store what we need for later. The important part is that we need to be able to access
	# x1 later, to branch there.
	stp xzr, x1, [sp, -16]!

	# Call the resume function. As a parameter it needs the current exception, and a pointer
	# to where it should store the stack pointer. x0 is already in the right place.
	mov x1, sp
	bl posixResumeException

	# Restore state, update sp and jump. We may not trash x0 here.
	ldp x2, x1, [sp]
	mov sp, x2
	br x1

#endif

	# No executable stack.
	.section .note.GNU-stack,"",%progbits