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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
;; Licensed to the .NET Foundation under one or more agreements.
;; The .NET Foundation licenses this file to you under the MIT license.
;; See the LICENSE file in the project root for more information.
;; -----------------------------------------------------------------------------------------------------------
;; #include "asmmacros.inc"
;; -----------------------------------------------------------------------------------------------------------
LEAF_ENTRY macro Name, Section
Section segment para 'CODE'
align 16
public Name
Name proc
endm
LEAF_END macro Name, Section
Name endp
Section ends
endm
; - TAILCALL_RAX: ("jmp rax") should be used for tailcalls, this emits an instruction
; sequence which is recognized by the unwinder as a valid epilogue terminator
TAILJMP_RAX TEXTEQU <DB 048h, 0FFh, 0E0h>
POINTER_SIZE equ 08h
;;
;; Note: The "__jmpstub__" prefix is used to indicate to debugger
;; that it must step-through this stub when it encounters it while
;; stepping.
;;
;;
;; __jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub
;;
;; r10 - AddressOfAddressOfFunctionToCallAfterDereferencingThis
;;
LEAF_ENTRY __jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub, _TEXT
mov rax, [r10] ; Tail jumps go through RAX, so copy function pointer there
mov rcx, [rcx] ; Deference this to get real function pointer
TAILJMP_RAX
LEAF_END __jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub, _TEXT
;;
;; void ConstrainedCallSupport_GetStubs(IntPtr *__jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub,
;; IntPtr *__jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub)
;;
LEAF_ENTRY ConstrainedCallSupport_GetStubs, _TEXT
lea rax, [__jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub]
mov [rcx], rax
lea rax, [__jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub]
mov [rdx], rax
ret
LEAF_END ConstrainedCallSupport_GetStubs, _TEXT
;;
;; __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub
;;
;; struct ConstrainedCallDesc
;; {
;; ULONG_PTR ExactTarget;
;; ULONG_PTR LookupFunc; // Put UniversalThunk here
;; }
;;
;; struct CommonCallingStubInputData
;; {
;; ULONG_PTR ConstrainedCallDesc;
;; ULONG_PTR DirectConstrainedCallResolver;
;; }
;;
;; r10 - Points at CommonCallingStubInputData
;;
;;
LEAF_ENTRY __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub, _TEXT
mov r11, [r10] ; put ConstrainedCallDesc into r11 (Arg to LookupFunc/Temp for getting ExactTarget)
mov rax, [r11] ; put ExactTarget into rax
test rax, rax ; compare against null
jnz JumpToTarget ; if not null, we don't need to call helper to get result. Just jump
; If we reach here, we need to use a universal thunk to call the LookupFunc
mov rax, [r11 + POINTER_SIZE] ; Get Universal thunk function pointer into rax
mov r10, [r10 + POINTER_SIZE] ; Put DirectConstrainedCallResolver into r10 for UniversalTransitionThunk call
JumpToTarget:
TAILJMP_RAX
LEAF_END __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub, _TEXT
end
|