|
8 | 8 | #include "cmplog.h"
|
9 | 9 | #endif
|
10 | 10 |
|
11 |
| -// Note: for RETADDR to give us the fuzz target caller address we need |
| 11 | +// Note: for RETADDR to give us the fuzz target caller address we need |
12 | 12 | // to guarantee that this code is inlined. `inline` keyword provides
|
13 | 13 | // no such guarantees, but a macro does.
|
14 | 14 | #ifdef SANCOV_VALUE_PROFILE
|
15 | 15 | #define SANCOV_VALUE_PROFILE_CALL(k, arg_size, arg1, arg2, arg1_is_const) \
|
16 |
| - k &= CMP_MAP_SIZE - 1; \ |
17 |
| - __libafl_targets_value_profile1(k, arg1, arg2); |
| 16 | + k &= CMP_MAP_SIZE - 1; \ |
| 17 | + __libafl_targets_value_profile##arg_size(k, arg1, arg2); |
18 | 18 | #else
|
19 | 19 | #define SANCOV_VALUE_PROFILE_CALL(k, arg_size, arg1, arg2, arg1_is_const)
|
20 | 20 | #endif
|
21 | 21 |
|
22 | 22 | #ifdef SANCOV_CMPLOG
|
23 |
| - #define SANCOV_CMPLOG_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
24 |
| - k &= CMPLOG_MAP_W - 1; \ |
25 |
| - cmplog_instructions_checked(k, arg_size, (uint64_t)arg1, (uint64_t)arg2, arg1_is_const); |
| 23 | + #define SANCOV_CMPLOG_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
| 24 | + k &= CMPLOG_MAP_W - 1; \ |
| 25 | + cmplog_instructions_checked(k, arg_size, (uint64_t)arg1, (uint64_t)arg2, \ |
| 26 | + arg1_is_const); |
26 | 27 | #else
|
27 | 28 | #define SANCOV_CMPLOG_CALL(k, arg_size, arg1, arg2, arg1_is_const)
|
28 | 29 | #endif
|
29 | 30 |
|
30 |
| -#define HANDLE_SANCOV_TRACE_CMP(arg_size, arg1, arg2, arg1_is_const) { \ |
31 |
| - uintptr_t k = RETADDR; \ |
32 |
| - k = (k >> 4) ^ (k << 8); \ |
33 |
| - SANCOV_VALUE_PROFILE_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
34 |
| - SANCOV_CMPLOG_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
35 |
| -} |
| 31 | +#define HANDLE_SANCOV_TRACE_CMP(arg_size, arg1, arg2, arg1_is_const) \ |
| 32 | + { \ |
| 33 | + uintptr_t k = RETADDR; \ |
| 34 | + k = (k >> 4) ^ (k << 8); \ |
| 35 | + SANCOV_VALUE_PROFILE_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
| 36 | + SANCOV_CMPLOG_CALL(k, arg_size, arg1, arg2, arg1_is_const) \ |
| 37 | + } |
36 | 38 |
|
37 | 39 | void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) {
|
38 | 40 | HANDLE_SANCOV_TRACE_CMP(1, arg1, arg2, 0);
|
@@ -80,7 +82,8 @@ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) {
|
80 | 82 | #endif
|
81 | 83 | #ifdef SANCOV_CMPLOG
|
82 | 84 | k &= CMPLOG_MAP_W - 1;
|
83 |
| - // Note: cases[i + 2] are the constant values, so keep them in arg1 and indicate that it's const |
| 85 | + // Note: cases[i + 2] are the constant values, so keep them in arg1 and |
| 86 | + // indicate that it's const |
84 | 87 | cmplog_instructions_checked(k, cases[1] / 8, cases[i + 2], val, 1);
|
85 | 88 | #endif
|
86 | 89 | }
|
|
0 commit comments