diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-01-14 19:09:29 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-01-14 19:09:29 +0000 |
| commit | cc10d5443280b66d53e0dbef8baf3b9eee1c9aea (patch) | |
| tree | b3bf5797cd902a2eba5da1384f30c1a7e8f6016e /compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp | |
| parent | 7892c37455d5890be86a02882381bd240661a0e1 (diff) | |
| download | bcm5719-llvm-cc10d5443280b66d53e0dbef8baf3b9eee1c9aea.tar.gz bcm5719-llvm-cc10d5443280b66d53e0dbef8baf3b9eee1c9aea.zip | |
[compiler-rt][UBSan] Sanitization for alignment assumptions.
Summary:
This is the compiler-rt part.
The clang part is D54589.
Reviewers: filcab, vsk, #sanitizers, vitalybuka, rsmith, morehouse
Reviewed By: morehouse
Subscribers: rjmccall, krytarowski, rsmith, kcc, srhines, kubamracek, dberris, llvm-commits
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D54590
llvm-svn: 351106
Diffstat (limited to 'compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp')
| -rw-r--r-- | compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp b/compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp new file mode 100644 index 00000000000..c100928fecd --- /dev/null +++ b/compiler-rt/test/fuzzer/AlignmentAssumptionTest.cpp @@ -0,0 +1,27 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Test for alignment assumption failure. + +#include <assert.h> +#include <climits> +#include <cstddef> +#include <cstdint> +#include <cstdlib> +#include <iostream> + +static volatile int32_t Sink; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + assert(Data); + if (Size > 0 && Data[0] == 'H') { + Sink = 1; + if (Size > 1 && Data[1] == 'i') { + Sink = 2; + if (Size > 2 && Data[2] == '!') { + __builtin_assume_aligned(Data, 0x80000000); + } + } + } + return 0; +} |

