[sancov][sanitizer-common] Correct sanitizer coverage point

Sanitizer coverage point should be the previous instruction PC of the
caller and the offset to the previous instruction might be different
on each CPU architecture.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D119233
This commit is contained in:
Xiaodong Liu 2022-02-24 17:14:24 +08:00 committed by Ben Shi
parent 46f6c834d9
commit 56b5f00186
1 changed files with 3 additions and 1 deletions

View File

@ -14,6 +14,7 @@
# include "sanitizer_allocator_internal.h" # include "sanitizer_allocator_internal.h"
# include "sanitizer_atomic.h" # include "sanitizer_atomic.h"
# include "sanitizer_common.h" # include "sanitizer_common.h"
# include "sanitizer_common/sanitizer_stacktrace.h"
# include "sanitizer_file.h" # include "sanitizer_file.h"
# include "sanitizer_interface_internal.h" # include "sanitizer_interface_internal.h"
@ -222,7 +223,8 @@ SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(const uptr* pcs,
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard, u32* guard) { SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard, u32* guard) {
if (!*guard) return; if (!*guard) return;
__sancov::pc_guard_controller.TracePcGuard(guard, GET_CALLER_PC() - 1); __sancov::pc_guard_controller.TracePcGuard(
guard, StackTrace::GetPreviousInstructionPc(GET_CALLER_PC()));
} }
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard_init, SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_pc_guard_init,