summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-09-30 17:49:48 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-09-30 17:49:48 +0000
commit0f6ecea9555533c4414cf6addd2ffed02c1938ec (patch)
treeb3cf0f719a54b3947fd72c859bafe02bc2b8607e /test
parent2b7e04031eae52b103c2dd20d4aaf6c4a9f7251e (diff)
downloadcompiler-rt-0f6ecea9555533c4414cf6addd2ffed02c1938ec.tar.gz
[msan] Intercept __getrlimit.
Summary: This interceptor is useful on its own, but the main purpose of this change is to intercept libpthread initialization on linux/glibc in order to run __msan_init before any .preinit_array constructors. We used to trigger on pthread_initialize_minimal -> getrlimit(), but that call has changed to __getrlimit at some point. Reviewers: vitalybuka, pcc Subscribers: jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68168 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@373239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/msan/preinit_array.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/msan/preinit_array.cpp b/test/msan/preinit_array.cpp
new file mode 100644
index 000000000..6f877bac0
--- /dev/null
+++ b/test/msan/preinit_array.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx_msan -O0 %s -o %t && %run %t
+
+#include <sanitizer/msan_interface.h>
+
+volatile int global;
+static void pre_ctor() {
+ volatile int local;
+ global = 42;
+ local = 42;
+}
+
+__attribute__((section(".preinit_array"), used)) void(*__local_pre_ctor)(void) = pre_ctor;
+
+int main(void) {
+ return 0;
+}