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