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
29 .macro LOAD_HANDLER_ADDR reg handler
30 #if !defined(XRAY_PIC)
31 adrp \reg, ASM_SYMBOL(\handler)
32 ldr \reg, [\reg, :lo12:ASM_SYMBOL(\handler)]
34 adrp \reg, :got:ASM_SYMBOL(\handler)
35 ldr \reg, [\reg, :got_lo12:ASM_SYMBOL(\handler)]
42 .global ASM_SYMBOL(__xray_FunctionEntry)
43 ASM_HIDDEN(__xray_FunctionEntry)
44 ASM_TYPE_FUNCTION(__xray_FunctionEntry)
45 ASM_SYMBOL(__xray_FunctionEntry):
46 /* Move the return address beyond the end of sled data. The 12 bytes of
47 data are inserted in the code of the runtime patch, between the call
48 instruction and the instruction returned into. The data contains 32
49 bits of instrumented function ID and 64 bits of the address of
50 the current trampoline. */
52 // Push the registers which may be modified by the handler function.
55 // Load the handler function pointer.
56 LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
58 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::ENTRY = 0.
61 // Call the handler with 2 parameters.
66 ASM_SIZE(__xray_FunctionEntry)
69 .global ASM_SYMBOL(__xray_FunctionExit)
70 ASM_HIDDEN(__xray_FunctionExit)
71 ASM_TYPE_FUNCTION(__xray_FunctionExit)
72 ASM_SYMBOL(__xray_FunctionExit):
73 /* Move the return address beyond the end of sled data. The 12 bytes of
74 data are inserted in the code of the runtime patch, between the call
75 instruction and the instruction returned into. The data contains 32
76 bits of instrumented function ID and 64 bits of the address of
77 the current trampoline. */
81 // Load the handler function pointer into x2.
82 LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
84 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::EXIT = 1.
87 // Call the handler with 2 parameters.
92 ASM_SIZE(__xray_FunctionExit)
95 .global ASM_SYMBOL(__xray_FunctionTailExit)
96 ASM_HIDDEN(__xray_FunctionTailExit)
97 ASM_TYPE_FUNCTION(__xray_FunctionTailExit)
98 ASM_SYMBOL(__xray_FunctionTailExit):
99 /* Move the return address beyond the end of sled data. The 12 bytes of
100 data are inserted in the code of the runtime patch, between the call
101 instruction and the instruction returned into. The data contains 32
102 bits of instrumented function ID and 64 bits of the address of
103 the current trampoline. */
105 // Save the registers which may be modified by the handler function.
107 // Load the handler function pointer into x2.
108 LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
110 // Set w0 to the function ID (w17). Set x1 to XRayEntryType::TAIL = 2.
113 // Call the handler with 2 parameters.
118 ASM_SIZE(__xray_FunctionTailExit)
121 .global ASM_SYMBOL(__xray_ArgLoggerEntry)
122 ASM_HIDDEN(__xray_ArgLoggerEntry)
123 ASM_TYPE_FUNCTION(__xray_ArgLoggerEntry)
124 ASM_SYMBOL(__xray_ArgLoggerEntry):
126 // Push the registers which may be modified by the handler function.
129 LOAD_HANDLER_ADDR x8, _ZN6__xray13XRayArgLoggerE
132 // Load the handler function pointer.
133 LOAD_HANDLER_ADDR x8, _ZN6__xray19XRayPatchedFunctionE
138 mov x1, #3 // XRayEntryType::LOG_ARGS_ENTRY
145 ASM_SIZE(__xray_ArgLoggerEntry)
147 // __xray_*Event have default visibility so that they can be referenced by user
148 // DSOs that do not link against the runtime.
149 .global ASM_SYMBOL(__xray_CustomEvent)
150 ASM_TYPE_FUNCTION(__xray_CustomEvent)
151 ASM_SYMBOL(__xray_CustomEvent):
153 LOAD_HANDLER_ADDR x8, _ZN6__xray22XRayPatchedCustomEventE
159 ASM_SIZE(__xray_CustomEvent)
161 .global ASM_SYMBOL(__xray_TypedEvent)
162 ASM_TYPE_FUNCTION(__xray_TypedEvent)
163 ASM_SYMBOL(__xray_TypedEvent):
165 LOAD_HANDLER_ADDR x8, _ZN6__xray21XRayPatchedTypedEventE
171 ASM_SIZE(__xray_TypedEvent)
173 NO_EXEC_STACK_DIRECTIVE