1 | #include "../builtins/assembly.h" |
2 | |
3 | .syntax unified |
4 | .arch armv6t2 |
5 | .fpu vfpv2 |
6 | .code 32 |
7 | .global _ZN6__xray19XRayPatchedFunctionE |
8 | |
9 | @ Word-aligned function entry point |
10 | .p2align 2 |
11 | @ Let C/C++ see the symbol |
12 | .global __xray_FunctionEntry |
13 | .hidden __xray_FunctionEntry |
14 | @ It preserves all registers except r0, r12(ip), r14(lr) and r15(pc) |
15 | @ Assume that "q" part of the floating-point registers is not used |
16 | @ for passing parameters to C/C++ functions. |
17 | .type __xray_FunctionEntry, %function |
18 | @ In C++ it is void extern "C" __xray_FunctionEntry(uint32_t FuncId) with |
19 | @ FuncId passed in r0 register. |
20 | __xray_FunctionEntry: |
21 | PUSH {r1-r3,lr} |
22 | @ Save floating-point parameters of the instrumented function |
23 | VPUSH {d0-d7} |
24 | MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16) |
25 | MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12) |
26 | LDR r2, [pc, r1] |
27 | @ Handler address is nullptr if handler is not set |
28 | CMP r2, #0 |
29 | BEQ FunctionEntry_restore |
30 | @ Function ID is already in r0 (the first parameter). |
31 | @ r1=0 means that we are tracing an entry event |
32 | MOV r1, #0 |
33 | @ Call the handler with 2 parameters in r0 and r1 |
34 | BLX r2 |
35 | FunctionEntry_restore: |
36 | @ Restore floating-point parameters of the instrumented function |
37 | VPOP {d0-d7} |
38 | POP {r1-r3,pc} |
39 | |
40 | @ Word-aligned function entry point |
41 | .p2align 2 |
42 | @ Let C/C++ see the symbol |
43 | .global __xray_FunctionExit |
44 | .hidden __xray_FunctionExit |
45 | @ Assume that d1-d7 are not used for the return value. |
46 | @ Assume that "q" part of the floating-point registers is not used for the |
47 | @ return value in C/C++. |
48 | .type __xray_FunctionExit, %function |
49 | @ In C++ it is extern "C" void __xray_FunctionExit(uint32_t FuncId) with |
50 | @ FuncId passed in r0 register. |
51 | __xray_FunctionExit: |
52 | PUSH {r1-r3,lr} |
53 | @ Save the floating-point return value of the instrumented function |
54 | VPUSH {d0} |
55 | @ Load the handler address |
56 | MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16) |
57 | MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12) |
58 | LDR r2, [pc, r1] |
59 | @ Handler address is nullptr if handler is not set |
60 | CMP r2, #0 |
61 | BEQ FunctionExit_restore |
62 | @ Function ID is already in r0 (the first parameter). |
63 | @ 1 means that we are tracing an exit event |
64 | MOV r1, #1 |
65 | @ Call the handler with 2 parameters in r0 and r1 |
66 | BLX r2 |
67 | FunctionExit_restore: |
68 | @ Restore the floating-point return value of the instrumented function |
69 | VPOP {d0} |
70 | POP {r1-r3,pc} |
71 | |
72 | @ Word-aligned function entry point |
73 | .p2align 2 |
74 | @ Let C/C++ see the symbol |
75 | .global __xray_FunctionTailExit |
76 | .hidden __xray_FunctionTailExit |
77 | @ It preserves all registers except r0, r12(ip), r14(lr) and r15(pc) |
78 | @ Assume that "q" part of the floating-point registers is not used |
79 | @ for passing parameters to C/C++ functions. |
80 | .type __xray_FunctionTailExit, %function |
81 | @ In C++ it is void extern "C" __xray_FunctionTailExit(uint32_t FuncId) |
82 | @ with FuncId passed in r0 register. |
83 | __xray_FunctionTailExit: |
84 | PUSH {r1-r3,lr} |
85 | @ Save floating-point parameters of the instrumented function |
86 | VPUSH {d0-d7} |
87 | MOVW r1, #:lower16:_ZN6__xray19XRayPatchedFunctionE - (. + 16) |
88 | MOVT r1, #:upper16:_ZN6__xray19XRayPatchedFunctionE - (. + 12) |
89 | LDR r2, [pc, r1] |
90 | @ Handler address is nullptr if handler is not set |
91 | CMP r2, #0 |
92 | BEQ FunctionTailExit_restore |
93 | @ Function ID is already in r0 (the first parameter). |
94 | @ r1=2 means that we are tracing a tail exit event |
95 | @ But before the logging part of XRay is ready, we pretend that here a |
96 | @ normal function exit happens, so we give the handler code 1 |
97 | MOV r1, #1 |
98 | @ Call the handler with 2 parameters in r0 and r1 |
99 | BLX r2 |
100 | FunctionTailExit_restore: |
101 | @ Restore floating-point parameters of the instrumented function |
102 | VPOP {d0-d7} |
103 | POP {r1-r3,pc} |
104 | |
105 | NO_EXEC_STACK_DIRECTIVE |
106 | |