1 #include "../builtins/assembly.h"
2 #include "../sanitizer_common/sanitizer_asm.h"
5 stp x1, x2, [sp, #-16]!
6 stp x3, x4, [sp, #-16]!
7 stp x5, x6, [sp, #-16]!
8 stp x7, x30, [sp, #-16]!
9 stp q0, q1, [sp, #-32]!
10 stp q2, q3, [sp, #-32]!
11 stp q4, q5, [sp, #-32]!
12 stp q6, q7, [sp, #-32]!
13 // x8 is the indirect result register and needs to be preserved for the body of the function to use.
14 stp x8, x0, [sp, #-16]!
17 .macro RESTORE_REGISTERS
23 ldp x7, x30, [sp], #16
31 .global ASM_SYMBOL(__xray_FunctionEntry)
32 ASM_HIDDEN(__xray_FunctionEntry)
33 ASM_TYPE_FUNCTION(__xray_FunctionEntry)
34 ASM_SYMBOL(__xray_FunctionEntry):
35 /* Move the return address beyond the end of sled data. The 12 bytes of
36 data are inserted in the code of the runtime patch, between the call
37 instruction and the instruction returned into. The data contains 32
38 bits of instrumented function ID and 64 bits of the address of
39 the current trampoline. */
41 // Push the registers which may be modified by the handler function.
44 // Load the handler function pointer.
45 adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
46 ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
48 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::ENTRY = 0.
51 // Call the handler with 2 parameters.
56 ASM_SIZE(__xray_FunctionEntry)
59 .global ASM_SYMBOL(__xray_FunctionExit)
60 ASM_HIDDEN(__xray_FunctionExit)
61 ASM_TYPE_FUNCTION(__xray_FunctionExit)
62 ASM_SYMBOL(__xray_FunctionExit):
63 /* Move the return address beyond the end of sled data. The 12 bytes of
64 data are inserted in the code of the runtime patch, between the call
65 instruction and the instruction returned into. The data contains 32
66 bits of instrumented function ID and 64 bits of the address of
67 the current trampoline. */
71 // Load the handler function pointer into x2.
72 adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
73 ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
75 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::EXIT = 1.
78 // Call the handler with 2 parameters.
83 ASM_SIZE(__xray_FunctionExit)
86 .global ASM_SYMBOL(__xray_FunctionTailExit)
87 ASM_HIDDEN(__xray_FunctionTailExit)
88 ASM_TYPE_FUNCTION(__xray_FunctionTailExit)
89 ASM_SYMBOL(__xray_FunctionTailExit):
90 /* Move the return address beyond the end of sled data. The 12 bytes of
91 data are inserted in the code of the runtime patch, between the call
92 instruction and the instruction returned into. The data contains 32
93 bits of instrumented function ID and 64 bits of the address of
94 the current trampoline. */
96 // Save the registers which may be modified by the handler function.
98 // Load the handler function pointer into x2.
99 adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
100 ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
102 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::TAIL = 2.
105 // Call the handler with 2 parameters.
110 ASM_SIZE(__xray_FunctionTailExit)
113 .global ASM_SYMBOL(__xray_ArgLoggerEntry)
114 ASM_HIDDEN(__xray_ArgLoggerEntry)
115 ASM_TYPE_FUNCTION(__xray_ArgLoggerEntry)
116 ASM_SYMBOL(__xray_ArgLoggerEntry):
118 // Push the registers which may be modified by the handler function.
121 adrp x8, ASM_SYMBOL(_ZN6__xray13XRayArgLoggerE)
122 ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray13XRayArgLoggerE)]
125 // Load the handler function pointer.
126 adrp x8, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
127 ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
132 mov x1, #3 // XRayEntryType::LOG_ARGS_ENTRY
139 ASM_SIZE(__xray_ArgLoggerEntry)
141 .global ASM_SYMBOL(__xray_CustomEvent)
142 ASM_HIDDEN(__xray_CustomEvent)
143 ASM_TYPE_FUNCTION(__xray_CustomEvent)
144 ASM_SYMBOL(__xray_CustomEvent):
146 adrp x8, ASM_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)
147 ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)]
153 ASM_SIZE(__xray_CustomEvent)
155 .global ASM_SYMBOL(__xray_TypedEvent)
156 ASM_HIDDEN(__xray_TypedEvent)
157 ASM_TYPE_FUNCTION(__xray_TypedEvent)
158 ASM_SYMBOL(__xray_TypedEvent):
160 adrp x8, ASM_SYMBOL(_ZN6__xray21XRayPatchedTypedEventE)
161 ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray21XRayPatchedTypedEventE)]
167 ASM_SIZE(__xray_TypedEvent)
169 NO_EXEC_STACK_DIRECTIVE