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
|
/*
* cepis_abi_probe(fn, a0, a1, a2, a3)
*
* Calls fn(a0, a1, a2, a3) with every callee-saved register holding a
* distinctive sentinel and returns a bitmask of the ones it came back
* clobbered, plus bits for a moved stack pointer and a left-over direction
* flag. 0 means the callee honoured the System V AMD64 ABI.
*
* Not part of the library: this file is only linked into the test driver.
*/
.text
.globl cepis_abi_probe
.type cepis_abi_probe, @function
.p2align 4
cepis_abi_probe:
push %rbp
mov %rsp, %rbp
push %rbx
push %r12
push %r13
push %r14
push %r15
sub $8, %rsp
mov %rbp, cepis__probe_bp(%rip)
mov %rsp, cepis__probe_sp(%rip)
mov %rdi, %rax
mov %rsi, %rdi
mov %rdx, %rsi
mov %rcx, %rdx
mov %r8, %rcx
movabs $0x1111111111111111, %rbx
movabs $0x2222222222222222, %r12
movabs $0x3333333333333333, %r13
movabs $0x4444444444444444, %r14
movabs $0x5555555555555555, %r15
movabs $0x6666666666666666, %rbp
call *%rax
xor %r8d, %r8d
movabs $0x1111111111111111, %r9
cmp %r9, %rbx
je .Lp_r12
or $1, %r8d
.Lp_r12:
movabs $0x2222222222222222, %r9
cmp %r9, %r12
je .Lp_r13
or $2, %r8d
.Lp_r13:
movabs $0x3333333333333333, %r9
cmp %r9, %r13
je .Lp_r14
or $4, %r8d
.Lp_r14:
movabs $0x4444444444444444, %r9
cmp %r9, %r14
je .Lp_r15
or $8, %r8d
.Lp_r15:
movabs $0x5555555555555555, %r9
cmp %r9, %r15
je .Lp_rbp
or $16, %r8d
.Lp_rbp:
movabs $0x6666666666666666, %r9
cmp %r9, %rbp
je .Lp_sp
or $32, %r8d
.Lp_sp:
mov cepis__probe_sp(%rip), %r9
cmp %r9, %rsp
je .Lp_df
or $64, %r8d
mov %r9, %rsp
.Lp_df:
pushfq
pop %r9
test $0x400, %r9d
jz .Lp_done
or $128, %r8d
cld
.Lp_done:
mov cepis__probe_bp(%rip), %rbp
mov %r8d, %eax
lea -40(%rbp), %rsp
pop %r15
pop %r14
pop %r13
pop %r12
pop %rbx
pop %rbp
ret
.size cepis_abi_probe, . - cepis_abi_probe
.data
.p2align 3
cepis__probe_bp:
.quad 0
cepis__probe_sp:
.quad 0
.section .note.GNU-stack,"",@progbits
|