brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 3ffc1e4 Raw
106 lines · plain
1#include "../builtins/assembly.h"2 3    .syntax unified4    .arch armv6t25    .fpu vfpv26    .code 327    .global _ZN6__xray19XRayPatchedFunctionE8 9    @ Word-aligned function entry point10    .p2align 211    @ Let C/C++ see the symbol12    .global __xray_FunctionEntry13    .hidden __xray_FunctionEntry14    @ 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 used16    @   for passing parameters to C/C++ functions.17    .type __xray_FunctionEntry, %function18    @ In C++ it is void extern "C" __xray_FunctionEntry(uint32_t FuncId) with19    @   FuncId passed in r0 register.20__xray_FunctionEntry:21    PUSH {r1-r3,lr}22    @ Save floating-point parameters of the instrumented function23    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 set28    CMP r2, #029    BEQ FunctionEntry_restore30    @ Function ID is already in r0 (the first parameter).31    @ r1=0 means that we are tracing an entry event32    MOV r1, #033    @ Call the handler with 2 parameters in r0 and r134    BLX r235FunctionEntry_restore:36    @ Restore floating-point parameters of the instrumented function37    VPOP {d0-d7}38    POP {r1-r3,pc}39 40    @ Word-aligned function entry point41    .p2align 242    @ Let C/C++ see the symbol43	.global __xray_FunctionExit44	.hidden __xray_FunctionExit45	@ 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 the47    @   return value in C/C++.48	.type __xray_FunctionExit, %function49	@ In C++ it is extern "C" void __xray_FunctionExit(uint32_t FuncId) with50    @   FuncId passed in r0 register.51__xray_FunctionExit:52    PUSH {r1-r3,lr}53    @ Save the floating-point return value of the instrumented function54    VPUSH {d0}55    @ Load the handler address56    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 set60    CMP r2, #061    BEQ FunctionExit_restore62    @ Function ID is already in r0 (the first parameter).63    @ 1 means that we are tracing an exit event64    MOV r1, #165    @ Call the handler with 2 parameters in r0 and r166    BLX r267FunctionExit_restore:68    @ Restore the floating-point return value of the instrumented function69    VPOP {d0}70    POP {r1-r3,pc}71 72    @ Word-aligned function entry point73    .p2align 274    @ Let C/C++ see the symbol75    .global __xray_FunctionTailExit76    .hidden __xray_FunctionTailExit77    @ 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 used79    @   for passing parameters to C/C++ functions.80    .type __xray_FunctionTailExit, %function81    @ 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 function86    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 set91    CMP r2, #092    BEQ FunctionTailExit_restore93    @ Function ID is already in r0 (the first parameter).94    @ r1=2 means that we are tracing a tail exit event95    @ But before the logging part of XRay is ready, we pretend that here a96    @   normal function exit happens, so we give the handler code 197    MOV r1, #198    @ Call the handler with 2 parameters in r0 and r199    BLX r2100FunctionTailExit_restore:101    @ Restore floating-point parameters of the instrumented function102    VPOP {d0-d7}103    POP {r1-r3,pc}104 105NO_EXEC_STACK_DIRECTIVE106