libhfuzz/instrument: rewrite sanitizer_cov_trace_pc_indir to use edge
@@ -83,7 +83,7 @@ ATTRIBUTE_X86_REQUIRE_SSE42 void __cyg_profile_func_exit(void *func UNUSED, void
}
/*
- * -fsanitize-coverage=trace-pc,indirect-calls,trace-cmp
+ * -fsanitize-coverage=trace-pc
*/
ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_pc(void)
{
@@ -94,20 +94,24 @@ ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_pc(void)
}
}
+/*
+ * -fsanitize-coverage=indirect-calls
+ */
ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_pc_indir(void *callee)
{
- register size_t pos = (uintptr_t) __builtin_return_address(0) & _HF_PERF_BITMAP_BITSZ_MASK;
+ register size_t pos1 = (uintptr_t) __builtin_return_address(0) << 12;
+ register size_t pos2 = (uintptr_t) callee & 0xFFF;
+ register size_t pos = (pos1 | pos2) & _HF_PERF_BITMAP_BITSZ_MASK;
+
register uint8_t prev = ATOMIC_BTS(feedback->bbMapPc, pos);
if (!prev) {
ATOMIC_PRE_INC_RELAXED(feedback->pidFeedbackPc[my_thread_no]);
}
- pos = (uintptr_t) callee & _HF_PERF_BITMAP_BITSZ_MASK;
- prev = ATOMIC_BTS(feedback->bbMapPc, pos);
- if (!prev) {
- ATOMIC_PRE_INC_RELAXED(feedback->pidFeedbackPc[my_thread_no]);
- }
}
+/*
+ * -fsanitize-coverage=trace-cmp
+ */
ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2)
{
uintptr_t pos = (uintptr_t) __builtin_return_address(0) % _HF_PERF_BITMAP_SIZE_16M;
@@ -170,7 +174,7 @@ ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_switch(uint64_t Val, uint
}
/*
- * -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
+ * -fsanitize-coverage=trace-pc-guard
*/
ATTRIBUTE_X86_REQUIRE_SSE42 void __sanitizer_cov_trace_pc_guard_init(uint32_t * start,
uint32_t * stop)
