pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Update to SVN r. 320165
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Fri Dec 8 19:44:11 2017 +0100
Changeset: 0e78e753164d43cd2da4ee0a458466b81b97e074
Modified Files:
compiler-rt-netbsd/Makefile
compiler-rt-netbsd/distinfo
compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
Log Message:
compiler-rt-netbsd: Update to SVN r. 320165
Backport again D40714:
Correct atexit(3) support in MSan/NetBSD
https://reviews.llvm.org/D40714
Sponsored by <The NetBSD Foundation>
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=0e78e753164d43cd2da4ee0a458466b81b97e074
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-netbsd/Makefile | 2 +-
compiler-rt-netbsd/distinfo | 2 +-
.../patches/patch-lib_msan_msan__interceptors.cc | 112 +++++++++++++++++++++
3 files changed, 114 insertions(+), 2 deletions(-)
diffs:
diff --git a/compiler-rt-netbsd/Makefile b/compiler-rt-netbsd/Makefile
index e2d3c6d403..f8d18be6c0 100644
--- a/compiler-rt-netbsd/Makefile
+++ b/compiler-rt-netbsd/Makefile
@@ -5,7 +5,7 @@ CATEGORIES= lang devel
SVN_REPOSITORIES= compiler-rt
SVN_REPO.compiler-rt= http://llvm.org/svn/llvm-project/compiler-rt/trunk
-SVN_REVISION.compiler-rt= 319967
+SVN_REVISION.compiler-rt= 320165
MAINTAINER= pkgsrc-users%NetBSD.org@localhost
HOMEPAGE= http://compiler-rt.llvm.org/
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 278745a7f5..0209b19a2b 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -4,7 +4,7 @@ SHA1 (patch-cmake_config-ix.cmake) = 5068232331d541c2786f01960a80e59252b1ad2c
SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
SHA1 (patch-lib_msan_msan.h) = 463509082f0b194f9439556632f37c637648802b
SHA1 (patch-lib_msan_msan__allocator.cc) = 582608180d48dc03cf5d89572489f522c36978f4
-SHA1 (patch-lib_msan_msan__interceptors.cc) = da39a3ee5e6b4b0d3255bfef95601890afd80709
+SHA1 (patch-lib_msan_msan__interceptors.cc) = ab97c2ecf0367fa5c78982b6402739ff160b1281
SHA1 (patch-lib_msan_msan__linux.cc) = d75d7587071a9e7a3f6a08a3008af55319e62cab
SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = ce8def76d88934a27cbb2f046c217368c83a7150
SHA1 (patch-lib_scudo_scudo__platform.h) = b3c23678b264ec7568c800bc95e949f1a9b65399
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
index e69de29bb2..03299e29b6 100644
--- a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
@@ -0,0 +1,112 @@
+$NetBSD$
+
+--- lib/msan/msan_interceptors.cc.orig 2017-12-08 18:38:11.810044075 +0000
++++ lib/msan/msan_interceptors.cc
+@@ -33,6 +33,7 @@
+ #include "sanitizer_common/sanitizer_libc.h"
+ #include "sanitizer_common/sanitizer_linux.h"
+ #include "sanitizer_common/sanitizer_tls_get_addr.h"
++#include "sanitizer_common/sanitizer_vector.h"
+
+ #if SANITIZER_NETBSD
+ #define gettimeofday __gettimeofday50
+@@ -1121,23 +1122,78 @@ struct MSanAtExitRecord {
+ void *arg;
+ };
+
+-void MSanAtExitWrapper(void *arg) {
++struct InterceptorContext {
++ BlockingMutex atexit_mu;
++ Vector<struct MSanAtExitRecord *> AtExitStack;
++
++ InterceptorContext()
++ : AtExitStack() {
++ }
++};
++
++static ALIGNED(64) char interceptor_placeholder[sizeof(InterceptorContext)];
++InterceptorContext *interceptor_ctx() {
++ return reinterpret_cast<InterceptorContext*>(&interceptor_placeholder[0]);
++}
++
++void MSanAtExitWrapper() {
++ MSanAtExitRecord *r;
++ {
++ BlockingMutexLock l(&interceptor_ctx()->atexit_mu);
++
++ uptr element = interceptor_ctx()->AtExitStack.Size() - 1;
++ r = interceptor_ctx()->AtExitStack[element];
++ interceptor_ctx()->AtExitStack.PopBack();
++ }
++
++ UnpoisonParam(1);
++ ((void(*)())r->func)();
++ InternalFree(r);
++}
++
++void MSanCxaAtExitWrapper(void *arg) {
+ UnpoisonParam(1);
+ MSanAtExitRecord *r = (MSanAtExitRecord *)arg;
+ r->func(r->arg);
+ InternalFree(r);
+ }
+
++static int setup_at_exit_wrapper(void(*f)(), void *arg, void *dso);
++
++// Unpoison argument shadow for C++ module destructors.
++INTERCEPTOR(int, atexit, void (*func)()) {
++ if (msan_init_is_running) return REAL(atexit)(func);
++ return setup_at_exit_wrapper((void(*)())func, 0, 0);
++}
++
+ // Unpoison argument shadow for C++ module destructors.
+ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
+ void *dso_handle) {
+ if (msan_init_is_running) return REAL(__cxa_atexit)(func, arg, dso_handle);
++ return setup_at_exit_wrapper((void(*)())func, arg, dso_handle);
++}
++
++static int setup_at_exit_wrapper(void(*f)(), void *arg, void *dso) {
+ ENSURE_MSAN_INITED();
+ MSanAtExitRecord *r =
+ (MSanAtExitRecord *)InternalAlloc(sizeof(MSanAtExitRecord));
+- r->func = func;
++ r->func = (void(*)(void *a))f;
+ r->arg = arg;
+- return REAL(__cxa_atexit)(MSanAtExitWrapper, r, dso_handle);
++ int res;
++ if (!dso) {
++ // NetBSD does not preserve the 2nd argument if dso is equal to 0
++ // Store ctx in a local stack-like structure
++
++ BlockingMutexLock l(&interceptor_ctx()->atexit_mu);
++
++ res = REAL(__cxa_atexit)((void (*)(void *a))MSanAtExitWrapper, 0, 0);
++ if (!res) {
++ interceptor_ctx()->AtExitStack.PushBack(r);
++ }
++ } else {
++ res = REAL(__cxa_atexit)(MSanCxaAtExitWrapper, r, dso);
++ }
++ return res;
+ }
+
+ static void BeforeFork() {
+@@ -1535,6 +1591,9 @@ namespace __msan {
+ void InitializeInterceptors() {
+ static int inited = 0;
+ CHECK_EQ(inited, 0);
++
++ new(interceptor_ctx()) InterceptorContext();
++
+ InitializeCommonInterceptors();
+ InitializeSignalInterceptors();
+
+@@ -1650,6 +1709,7 @@ void InitializeInterceptors() {
+
+ INTERCEPT_FUNCTION(pthread_join);
+ INTERCEPT_FUNCTION(tzset);
++ INTERCEPT_FUNCTION(atexit);
+ INTERCEPT_FUNCTION(__cxa_atexit);
+ INTERCEPT_FUNCTION(shmat);
+ INTERCEPT_FUNCTION(fork);
Home |
Main Index |
Thread Index |
Old Index