• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Code Intelligence GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstdint>
20 
21 // This file declares variants of the libFuzzer compare, division, switch and
22 // gep hooks that accept an additional caller_pc argument that can be used to
23 // pass a custom value that is recorded as the caller's instruction pointer
24 // ("program counter"). This allows synthetic program counters obtained from
25 // Java coverage information to be used with libFuzzer's value profile, with
26 // which it records detailed information about the result of compares and
27 // associates it with particular coverage locations.
28 //
29 // Note: Only the lower 9 bits of the caller_pc argument are used by libFuzzer.
30 extern "C" {
31 void __sanitizer_cov_trace_cmp4_with_pc(void *caller_pc, uint32_t arg1,
32                                         uint32_t arg2);
33 void __sanitizer_cov_trace_cmp8_with_pc(void *caller_pc, uint64_t arg1,
34                                         uint64_t arg2);
35 
36 void __sanitizer_cov_trace_switch_with_pc(void *caller_pc, uint64_t val,
37                                           uint64_t *cases);
38 
39 void __sanitizer_cov_trace_div4_with_pc(void *caller_pc, uint32_t val);
40 void __sanitizer_cov_trace_div8_with_pc(void *caller_pc, uint64_t val);
41 
42 void __sanitizer_cov_trace_gep_with_pc(void *caller_pc, uintptr_t idx);
43 
44 void __sanitizer_cov_trace_pc_indir_with_pc(void *caller_pc, uintptr_t callee);
45 }
46 
47 void CalibrateTrampoline();
48