summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
diff options
context:
space:
mode:
authorJake Ehrlich <jakehehrlich@google.com>2019-09-17 00:34:41 +0000
committerJake Ehrlich <jakehehrlich@google.com>2019-09-17 00:34:41 +0000
commit4b23c24bc8ec84ab443df42c9fdfc74de964febb (patch)
tree21f3bb16d21d5c9286ebe3ce8679dff455daa2c9 /compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
parent895eae309943428634cca1fde9e8bf3a6c171acf (diff)
downloadbcm5719-llvm-4b23c24bc8ec84ab443df42c9fdfc74de964febb.tar.gz
bcm5719-llvm-4b23c24bc8ec84ab443df42c9fdfc74de964febb.zip
[libFuzzer] Always print DSO map on Fuchsia libFuzzer launch
Fuchsia doesn't have /proc/id/maps, so it relies on the kernel logging system to provide the DSO map to be able to symbolize in the context of ASLR. The DSO map is logged automatically on Fuchsia when encountering a crash or writing to the sanitizer log for the first time in a process. There are several cases where libFuzzer doesn't encounter a crash, e.g. on timeouts, OOMs, and when configured to print new PCs as they become covered, to name a few. Therefore, this change always writes to the sanitizer log on startup to ensure the DSO map is available in the log. Author: aarongreen Differential Revision: https://reviews.llvm.org/D66233 llvm-svn: 372056
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
index 1f04b33c154..36010f7f1d7 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -311,6 +311,17 @@ bool Mprotect(void *Ptr, size_t Size, bool AllowReadWrite) {
// Platform specific functions.
void SetSignalHandler(const FuzzingOptions &Options) {
+ // Make sure information from libFuzzer and the sanitizers are easy to
+ // reassemble. `__sanitizer_log_write` has the added benefit of ensuring the
+ // DSO map is always available for the symbolizer.
+ // A uint64_t fits in 20 chars, so 64 is plenty.
+ char Buf[64];
+ memset(Buf, 0, sizeof(Buf));
+ snprintf(Buf, sizeof(Buf), "==%lu== INFO: libFuzzer starting.\n", GetPid());
+ if (EF->__sanitizer_log_write)
+ __sanitizer_log_write(Buf, sizeof(Buf));
+ Printf("%s", Buf);
+
// Set up alarm handler if needed.
if (Options.UnitTimeoutSec > 0) {
std::thread T(AlarmHandler, Options.UnitTimeoutSec / 2 + 1);
OpenPOWER on IntegriCloud