Summary: optional/options_parser and optional/backtrace_sanitizer_common are logically separate components. They both use sanitizer-common to power their functionality, but there was an unstated implicit dependency that in order for backtrace_sanitizer_common to function correctly, one had to also use options_parser. This was because options_parser called __sanitizer::InitialiseCommonFlags. This is a requirement for backtrace_sanitizer_common to work, as the sanitizer unwinder uses the sanitizer_common flags and will SEGV on a null page if they're not initialised correctly. This patch removes this hidden dependency. You can now use backtrace_sanitizer_common without the requirements of options_parser. This patch also makes the GWP-ASan unit tests only have a soft dependency on sanitizer-common. The unit tests previously explicitly used __sanitizer::Printf, which is now provided under tests/optional/printf_sanitizer_common. This allows Android to build the unit tests using their own signal-safe printf(). Reviewers: eugenis Reviewed By: eugenis Subscribers: srhines, mgorny, #sanitizers, llvm-commits, vlad.tsyrklevich, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66684 llvm-svn: 369825
23 lines
843 B
C++
23 lines
843 B
C++
//===-- printf_sanitizer_common.cpp -----------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
#include "gwp_asan/options.h"
|
|
|
|
namespace gwp_asan {
|
|
namespace test {
|
|
// This printf-function getter allows other platforms (e.g. Android) to define
|
|
// their own signal-safe Printf function. In LLVM, we use
|
|
// `optional/printf_sanitizer_common.cpp` which supplies the __sanitizer::Printf
|
|
// for this purpose.
|
|
options::Printf_t getPrintfFunction() {
|
|
return __sanitizer::Printf;
|
|
}
|
|
}; // namespace test
|
|
}; // namespace gwp_asan
|