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
|
;; 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 "kxarm.h"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ConstrainedCall Support Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Note: The "__jmpstub__" prefix is used to indicate to debugger
;; that it must step-through this stub when it encounters it while
;; stepping.
;;
;;
;; sp-4 - AddressOfAddressOfFunctionToCallAfterDereferencingThis
;;
LEAF_ENTRY __jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub
ldr r12, [sp, #-4]
ldr r12, [r12]
ldr r0, [r0]
bx r12
LEAF_END __jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub
;;
;; void ConstrainedCallSupport_GetStubs(IntPtr *__jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub,
;; IntPtr *__jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub)
;;
LEAF_ENTRY ConstrainedCallSupport_GetStubs
ldr r12, =__jmpstub__ConstrainedCallSupport_DerefThisAndCall_CommonCallingStub
str r12, [r0]
ldr r12, =__jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub
str r12, [r1]
bx lr
LEAF_END ConstrainedCallSupport_GetStubs
;;
;; __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub
;;
;; struct ConstrainedCallDesc
;; {
;; ULONG_PTR ExactTarget;
;; ULONG_PTR LookupFunc; // Put UniversalThunk here
;; }
;;
;; struct CommonCallingStubInputData
;; {
;; ULONG_PTR ConstrainedCallDesc;
;; ULONG_PTR DirectConstrainedCallResolver;
;; }
;;
;; sp-4 - Points at CommonCallingStubInputData
;;
;;
LEAF_ENTRY __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub
ldr r12, [sp, #-4] ; put CommonCallingStubInputData into r12 (Temp for getting ExactTarget)
ldr r12, [r12] ; put ConstrainedCallDesc into r12 (Temp for getting ExactTarget)
ldr r12, [r12] ; put ExactTarget into r12
cmp r12, 0 ; Is ExactTarget null?
beq NeedHelperCall ; if null use a helper call
bx r12 ; Otherwise tail-call the ExactTarget
NeedHelperCall
;; Setup arguments for UniversalThunk and call it.
ldr r12, [sp, #-4] ; put CommonCallingStubInputData into r12 (Temp for getting ConstrainedCallDesc)
ldr r12, [r12] ; put ConstrainedCallDesc into r12
str r12, [sp, #-8] ; put ConstrainedCallDesc into sp-8 (red zone location of custom calling convention for universal thunk)
ldr r12, [sp, #-4] ; put CommonCallingStubInputData into r12 (Temp for getting DirectConstrainedCallResolver)
ldr r12, [r12, #4] ; put DirectConstrainedCallResolver into r12
str r12, [sp, #-4] ; put DirectConstrainedCallResolver into sp-4 (red zone location of custom calling convention for universal thunk)
ldr r12, [sp, #-8] ; put ConstrainedCallDesc into r12 (Temp for getting ExactTarget)
ldr r12, [r12, #4] ; put LookupFunc into r12 (This should be universal thunk pointer)
bx r12 ; Tail-Call Universal thunk
LEAF_END __jmpstub__ConstrainedCallSupport_DirectConstrainedCallCommonStub
END
|