diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-08-06 08:41:53 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-08-06 08:41:53 +0000 |
commit | ac9ee01fcbfac745aaedca0393a8e1c8a33acd8d (patch) | |
tree | 5875b4f3dc40ab82c40a67c1dab8645d554d1f4f /compiler-rt/test | |
parent | dba4dd1e8da4c168a4dacb47099132f0bad925f4 (diff) | |
download | bcm5719-llvm-ac9ee01fcbfac745aaedca0393a8e1c8a33acd8d.tar.gz bcm5719-llvm-ac9ee01fcbfac745aaedca0393a8e1c8a33acd8d.zip |
[compiler-rt] Implement getrandom interception
Summary:
Straightforward implementation of `getrandom` syscall and libc
hooks.
Test Plan: Local MSAN failures caused by uninstrumented `getrandom`
calls stop failing.
Patch by Andrew Krieger.
Reviewers: eugenis, vitalybuka
Reviewed By: vitalybuka
Subscribers: srhines, kubamracek, dberris, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D65551
llvm-svn: 367999
Diffstat (limited to 'compiler-rt/test')
-rw-r--r-- | compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp new file mode 100644 index 00000000000..08337f537d1 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp @@ -0,0 +1,22 @@ +// RUN: %clangxx -O2 %s -o %t && %run %t +// UNSUPPORTED: android +// + +#include <sys/types.h> + +#if !defined(__GLIBC_PREREQ) +#define __GLIBC_PREREQ(a, b) 0 +#endif + +#if __GLIBC_PREREQ(2, 25) +#include <sys/random.h> +#endif + +int main() { + char buf[16]; + ssize_t n = 1; +#if __GLIBC_PREREQ(2, 25) + n = getrandom(buf, sizeof(buf), 0); +#endif + return (int)(n <= 0); +} |