xray_trampoline_mips.S
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//===-- xray_trampoline_mips.s ----------------------------------*- ASM -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of XRay, a dynamic runtime instrumentation system.
//
// This implements the MIPS-specific assembler for the trampolines.
//
//===----------------------------------------------------------------------===//
.text
.file "xray_trampoline_mips.S"
.globl __xray_FunctionEntry
.p2align 2
.type __xray_FunctionEntry,@function
__xray_FunctionEntry:
.cfi_startproc
.set noreorder
.cpload $t9
.set reorder
// Save argument registers before doing any actual work
.cfi_def_cfa_offset 36
addiu $sp, $sp, -36
sw $ra, 32($sp)
.cfi_offset 31, -4
sw $a3, 28($sp)
sw $a2, 24($sp)
sw $a1, 20($sp)
sw $a0, 16($sp)
sdc1 $f14, 8($sp)
sdc1 $f12, 0($sp)
la $t9, _ZN6__xray19XRayPatchedFunctionE
lw $t9, 0($t9)
beqz $t9, FunctionEntry_restore
// a1=0 means that we are tracing an entry event
move $a1, $zero
// Function ID is in t0 (the first parameter).
move $a0, $t0
jalr $t9
FunctionEntry_restore:
// Restore argument registers
ldc1 $f12, 0($sp)
ldc1 $f14, 8($sp)
lw $a0, 16($sp)
lw $a1, 20($sp)
lw $a2, 24($sp)
lw $a3, 28($sp)
lw $ra, 32($sp)
addiu $sp, $sp, 36
jr $ra
FunctionEntry_end:
.size __xray_FunctionEntry, FunctionEntry_end-__xray_FunctionEntry
.cfi_endproc
.text
.globl __xray_FunctionExit
.p2align 2
.type __xray_FunctionExit,@function
__xray_FunctionExit:
.cfi_startproc
.set noreorder
.cpload $t9
.set reorder
// Save return registers before doing any actual work.
.cfi_def_cfa_offset 36
addiu $sp, $sp, -36
sw $ra, 32($sp)
.cfi_offset 31, -4
sw $a1, 28($sp)
sw $a0, 24($sp)
sw $v1, 20($sp)
sw $v0, 16($sp)
sdc1 $f2, 8($sp)
sdc1 $f0, 0($sp)
la $t9, _ZN6__xray19XRayPatchedFunctionE
lw $t9, 0($t9)
beqz $t9, FunctionExit_restore
// a1=1 means that we are tracing an exit event
li $a1, 1
// Function ID is in t0 (the first parameter).
move $a0, $t0
jalr $t9
FunctionExit_restore:
// Restore return registers
ldc1 $f0, 0($sp)
ldc1 $f2, 8($sp)
lw $v0, 16($sp)
lw $v1, 20($sp)
lw $a0, 24($sp)
lw $a1, 28($sp)
lw $ra, 32($sp)
addiu $sp, $sp, 36
jr $ra
FunctionExit_end:
.size __xray_FunctionExit, FunctionExit_end-__xray_FunctionExit
.cfi_endproc