pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Scratch of VM mapping of a process for tsan
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Thu Oct 5 17:07:22 2017 +0200
Changeset: f295f45664e3b7d5ab3bed4d94dd7bb60fce0de7
Modified Files:
compiler-rt-netbsd/distinfo
Added Files:
compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform.h
compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__posix.cc
Log Message:
compiler-rt-netbsd: Scratch of VM mapping of a process for tsan
Build-tested.
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=f295f45664e3b7d5ab3bed4d94dd7bb60fce0de7
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-netbsd/distinfo | 2 +
.../patches/patch-lib_tsan_rtl_tsan__platform.h | 107 +++++++++++++++++++++
.../patch-lib_tsan_rtl_tsan__platform__posix.cc | 15 +++
3 files changed, 124 insertions(+)
diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index b18a26832d..48b73f2d9b 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -4,7 +4,9 @@ SHA1 (patch-cmake_config-ix.cmake) = 5b1842f08cc8c2b96e0529b552b09c7adf2065dc
SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = eaffd9f8f2621ad465b5c734a764bdff0243af3d
SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 25cba9ff9d61910bb74d500e515da083af4e6cb7
SHA1 (patch-lib_tsan_go_buildgo.sh) = fe64b3389bbf6ae2ddf187df3e0600b2f817f51d
+SHA1 (patch-lib_tsan_rtl_tsan__platform.h) = 9ba65b81bb95bdf3b949da801cb9b97bf94174c4
SHA1 (patch-lib_tsan_rtl_tsan__platform__linux.cc) = 21424d5506d02887a15183285ecb564d9560f215
+SHA1 (patch-lib_tsan_rtl_tsan__platform__posix.cc) = ddf48d91100e681f09b7303a37936ac8cd7f775a
SHA1 (patch-lib_tsan_rtl_tsan__rtl__amd64.S) = 95591667c23372ceb72334b2ceae800d32574ac6
SHA1 (patch-lib_tsan_tests_rtl_tsan__test__util__posix.cc) = 302c72dab4fe5a0c94d7de0d728033e616811e5e
SHA1 (patch-test_tsan_lit.cfg) = c849d08c3df59a3de45c6515e05c3d9fac5424e7
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform.h b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform.h
new file mode 100644
index 0000000000..57e1b80b9d
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform.h
@@ -0,0 +1,107 @@
+$NetBSD$
+
+--- lib/tsan/rtl/tsan_platform.h.orig 2017-10-05 14:37:53.556451290 +0000
++++ lib/tsan/rtl/tsan_platform.h
+@@ -26,7 +26,68 @@ namespace __tsan {
+
+ #if !SANITIZER_GO
+
+-#if defined(__x86_64__)
++#if SANITIZER_NETBSD
++/*
++C/C++ on NetBSD/x86_64
++
++On exec() kernel maps program segments (.text, .data, .rodata...), stack and
++interpreter (if a dynamic loadable executable). Interpeter (usually ld.elf_so)
++maps into the vmmap shared libraries on the heap.
++
++The program segments are loaded on the beginning (alternatively there were
++pointed out by the ELF metadata) on the virtual address space, and the stack is
++mapped on the end of virtual address space available for user programs
++(7f7f ffff f000).
++
++AMD64 stack grows downwards and has prereserved 128GB of memory.
++There comes barrier and linker under the stack.
++
++Heap starts after another gap and goes downwards.
++
++PIE programs have randomized (ASLR) main binary segments.
++
++The position of stack, linker, heap is by default randomized by ASLR.
++The NetBSD version of ASLR can shift a mapping by 0-64MB.
++
++The first page (address 0x0) cannot be mapped (vm.user_va0_disable)
++in normal circumsances.
++
++0000 0000 1000 - 0080 0000 0000: main binary
++ : -
++0100 0000 0000 - 2000 0000 0000: shadow
++ : -
++3000 0000 0000 - 4000 0000 0000: metainfo (memory blocks and sync objects)
++ : -
++6000 0000 0000 - 6200 0000 0000: traces
++ : -
++7000 0000 0000 - 7c00 0000 0000: heap and dynamically loaded shared libraries
++ : -
++7e00 0000 0000 - 7f7f ffff f000: main thread stack and ld.so_elf
++*/
++struct Mapping {
++ static const uptr kLoAppMemBeg = 0x000000000000ull;
++ static const uptr kLoAppMemEnd = 0x008000000000ull;
++
++ static const uptr kShadowBeg = 0x010000000000ull;
++ static const uptr kShadowEnd = 0x200000000000ull;
++
++ static const uptr kMetaShadowBeg = 0x300000000000ull;
++ static const uptr kMetaShadowEnd = 0x340000000000ull;
++
++ static const uptr kTraceMemBeg = 0x600000000000ull;
++ static const uptr kTraceMemEnd = 0x620000000000ull;
++
++ static const uptr kHeapMemBeg = 0x780000000000ull;
++ static const uptr kHeapMemEnd = 0x7c0000000000ull;
++
++ static const uptr kHiAppMemBeg = 0x7e0000000000ull;
++ static const uptr kHiAppMemEnd = 0x7f7ffffff000ull;
++
++ static const uptr kAppMemMsk = 0x780000000000ull;
++ static const uptr kAppMemXor = 0x040000000000ull;
++};
++
++#elif defined(__x86_64__)
+ /*
+ C/C++ on linux/x86_64 and freebsd/x86_64
+ 0000 0000 1000 - 0080 0000 0000: main binary and/or MAP_32BIT mappings (512GB)
+@@ -387,7 +448,9 @@ enum MappingType {
+ MAPPING_META_SHADOW_END,
+ MAPPING_TRACE_BEG,
+ MAPPING_TRACE_END,
++#if !SANITIZER_NETBSD
+ MAPPING_VDSO_BEG,
++#endif
+ };
+
+ template<typename Mapping, int Type>
+@@ -404,7 +467,9 @@ uptr MappingImpl(void) {
+ case MAPPING_HI_APP_END: return Mapping::kHiAppMemEnd;
+ case MAPPING_HEAP_BEG: return Mapping::kHeapMemBeg;
+ case MAPPING_HEAP_END: return Mapping::kHeapMemEnd;
++#if !SANITIZER_NETBSD
+ case MAPPING_VDSO_BEG: return Mapping::kVdsoBeg;
++#endif
+ #else
+ case MAPPING_APP_BEG: return Mapping::kAppMemBeg;
+ case MAPPING_APP_END: return Mapping::kAppMemEnd;
+@@ -478,10 +543,12 @@ uptr HiAppMemEnd(void) {
+ return MappingArchImpl<MAPPING_HI_APP_END>();
+ }
+
++#if !SANITIZER_NETBSD
+ ALWAYS_INLINE
+ uptr VdsoBeg(void) {
+ return MappingArchImpl<MAPPING_VDSO_BEG>();
+ }
++#endif
+
+ #else
+
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__posix.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__posix.cc
new file mode 100644
index 0000000000..fd5cb667fc
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__posix.cc
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- lib/tsan/rtl/tsan_platform_posix.cc.orig 2017-07-16 22:40:10.000000000 +0000
++++ lib/tsan/rtl/tsan_platform_posix.cc
+@@ -124,8 +124,10 @@ void CheckAndProtect() {
+ if (segment.start >= HeapMemEnd() && segment.start < HeapEnd()) continue;
+ if (segment.protection == 0) // Zero page or mprotected.
+ continue;
++#if !SANITIZER_NETBSD
+ if (segment.start >= VdsoBeg()) // vdso
+ break;
++#endif
+ Printf("FATAL: ThreadSanitizer: unexpected memory mapping %p-%p\n",
+ segment.start, segment.end);
+ Die();
Home |
Main Index |
Thread Index |
Old Index