Source file
src/runtime/libfuzzer.go
Documentation: runtime
1
2
3
4
5
6
7 package runtime
8
9 import "unsafe"
10
11 func libfuzzerCallWithTwoByteBuffers(fn, start, end *byte)
12 func libfuzzerCallTraceIntCmp(fn *byte, arg0, arg1, fakePC uintptr)
13 func libfuzzerCall4(fn *byte, fakePC uintptr, s1, s2 unsafe.Pointer, result uintptr)
14
15
16 const retSledSize = 512
17
18
19
20
21
22
23 func libfuzzerTraceCmp1(arg0, arg1 uint8, fakePC uint) {
24 fakePC = fakePC % retSledSize
25 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp1, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
26 }
27
28
29 func libfuzzerTraceCmp2(arg0, arg1 uint16, fakePC uint) {
30 fakePC = fakePC % retSledSize
31 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp2, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
32 }
33
34
35 func libfuzzerTraceCmp4(arg0, arg1 uint32, fakePC uint) {
36 fakePC = fakePC % retSledSize
37 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp4, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
38 }
39
40
41 func libfuzzerTraceCmp8(arg0, arg1 uint64, fakePC uint) {
42 fakePC = fakePC % retSledSize
43 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp8, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
44 }
45
46
47 func libfuzzerTraceConstCmp1(arg0, arg1 uint8, fakePC uint) {
48 fakePC = fakePC % retSledSize
49 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_const_cmp1, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
50 }
51
52
53 func libfuzzerTraceConstCmp2(arg0, arg1 uint16, fakePC uint) {
54 fakePC = fakePC % retSledSize
55 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_const_cmp2, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
56 }
57
58
59 func libfuzzerTraceConstCmp4(arg0, arg1 uint32, fakePC uint) {
60 fakePC = fakePC % retSledSize
61 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_const_cmp4, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
62 }
63
64
65 func libfuzzerTraceConstCmp8(arg0, arg1 uint64, fakePC uint) {
66 fakePC = fakePC % retSledSize
67 libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_const_cmp8, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
68 }
69
70 var pcTables []byte
71
72 func init() {
73 libfuzzerCallWithTwoByteBuffers(&__sanitizer_cov_8bit_counters_init, &__start___sancov_cntrs, &__stop___sancov_cntrs)
74 start := unsafe.Pointer(&__start___sancov_cntrs)
75 end := unsafe.Pointer(&__stop___sancov_cntrs)
76
77
78
79
80
81 size := (uintptr(end)-uintptr(start))*unsafe.Sizeof(uintptr(0))*2 + 1
82 pcTables = make([]byte, size)
83 libfuzzerCallWithTwoByteBuffers(&__sanitizer_cov_pcs_init, &pcTables[0], &pcTables[size-1])
84 }
85
86
87
88
89
90
91
92
93
94
95
96
97 func libfuzzerHookStrCmp(s1, s2 string, fakePC int) {
98 if s1 != s2 {
99 libfuzzerCall4(&__sanitizer_weak_hook_strcmp, uintptr(fakePC), cstring(s1), cstring(s2), uintptr(1))
100 }
101
102
103 }
104
105
106
107
108
109 func libfuzzerHookEqualFold(s1, s2 string, fakePC int) {
110 if s1 != s2 {
111 libfuzzerCall4(&__sanitizer_weak_hook_strcmp, uintptr(fakePC), cstring(s1), cstring(s2), uintptr(1))
112 }
113 }
114
115
116
117 var __sanitizer_cov_trace_cmp1 byte
118
119
120
121 var __sanitizer_cov_trace_cmp2 byte
122
123
124
125 var __sanitizer_cov_trace_cmp4 byte
126
127
128
129 var __sanitizer_cov_trace_cmp8 byte
130
131
132
133 var __sanitizer_cov_trace_const_cmp1 byte
134
135
136
137 var __sanitizer_cov_trace_const_cmp2 byte
138
139
140
141 var __sanitizer_cov_trace_const_cmp4 byte
142
143
144
145 var __sanitizer_cov_trace_const_cmp8 byte
146
147
148
149 var __sanitizer_cov_8bit_counters_init byte
150
151
152 var __start___sancov_cntrs, __stop___sancov_cntrs byte
153
154
155
156 var __sanitizer_cov_pcs_init byte
157
158
159
160 var __sanitizer_weak_hook_strcmp byte
161
View as plain text