pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-netbsd: More glue for NetBSD support in sanitizers



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Jun 4 12:48:18 2017 +0200
Changeset:	2a6d4eae6856d98601214b2d4286771764b23f93

Modified Files:
	compiler-rt-netbsd/distinfo
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform.h
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc

Log Message:
compiler-rt-netbsd: More glue for NetBSD support in sanitizers

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=2a6d4eae6856d98601214b2d4286771764b23f93

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 +
 ...tch-lib_sanitizer__common_sanitizer__platform.h | 35 +++++++++
 ...anitizer__common_sanitizer__procmaps__netbsd.cc | 83 ++++++++++++++++++++++
 3 files changed, 120 insertions(+)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index cc02e1b39e..1607d8e580 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -16,6 +16,8 @@ SHA1 (patch-cmake_config-ix.cmake) = 6b0644c422eaf3e2721398c2575e31e07b535984
 SHA1 (patch-lib_asan_scripts_asan__symbolize.py) = d6c079e7092b22b5379293dbb8d1e2445e077932
 SHA1 (patch-lib_builtins_gcc__personality__v0.c) = 0a48656e68614730ea05e8fb2588434e774b3c45
 SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = 45b18179c5d1d9f284ccfe4670a989ac30d05e92
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform.h) = 47360a8352cc34fddc71c8f71081d7d589a63dad
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = 0b8d88529f7374a1159c65c0bccd946ccf6a65f3
 SHA1 (patch-test_asan_lit.cfg) = 259b0e262b5975b862a51f015ec6b646ce2af10a
 SHA1 (patch-test_sanitizer__common_CMakeLists.txt) = 6af4c5ca42f17bb09823c36bf32d5576fbc0b4c8
 SHA1 (patch-test_ubsan_lit.common.cfg) = d60d738aaf8525cf3f5f028dc2fc2fe54a7d691b
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform.h
new file mode 100644
index 0000000000..406c5382bd
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform.h
@@ -0,0 +1,35 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_platform.h.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/sanitizer_common/sanitizer_platform.h
+@@ -13,7 +13,7 @@
+ #ifndef SANITIZER_PLATFORM_H
+ #define SANITIZER_PLATFORM_H
+ 
+-#if !defined(__linux__) && !defined(__FreeBSD__) && \
++#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
+   !defined(__APPLE__) && !defined(_WIN32)
+ # error "This operating system is not supported"
+ #endif
+@@ -30,6 +30,12 @@
+ # define SANITIZER_FREEBSD 0
+ #endif
+ 
++#if defined(__NetBSD__)
++# define SANITIZER_NETBSD 1
++#else
++# define SANITIZER_NETBSD 0
++#endif
++
+ #if defined(__APPLE__)
+ # define SANITIZER_MAC     1
+ # include <TargetConditionals.h>
+@@ -79,7 +85,7 @@
+ # define SANITIZER_ANDROID 0
+ #endif
+ 
+-#define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC)
++#define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || SANITIZER_MAC)
+ 
+ #if __LP64__ || defined(_WIN64)
+ #  define SANITIZER_WORDSIZE 64
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
new file mode 100644
index 0000000000..cab83cdcba
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
@@ -0,0 +1,83 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig	2017-06-04 10:44:01.380040884 +0000
++++ lib/sanitizer_common/sanitizer_procmaps_netbsd.cc
+@@ -0,0 +1,78 @@
++//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===//
++//
++// This file is distributed under the University of Illinois Open Source
++// License. See LICENSE.TXT for details.
++//
++//===----------------------------------------------------------------------===//
++//
++// Information about the process mappings (FreeBSD-specific parts).
++//===----------------------------------------------------------------------===//
++
++#include "sanitizer_platform.h"
++#if SANITIZER_NETBSD
++#include "sanitizer_common.h"
++#include "sanitizer_procmaps.h"
++
++#include <unistd.h>
++#include <sys/sysctl.h>
++#include <sys/user.h>
++
++namespace __sanitizer {
++
++void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
++  struct kinfo_vmentry *kiv;
++  const int Mib[] = { CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(*kiv) };
++  size_t Size = 0;
++  int Err = sysctl(Mib, __arraycount(Mib), NULL, &Size, NULL, 0);
++  CHECK_EQ(Err, 0);
++  CHECK_GT(Size, 0);
++
++  size_t MmapedSize = Size * 4 / 3;
++  void *VmMap = MmapOrDie(MmapedSize, "ReadProcMaps()");
++  Size = MmapedSize;
++  Err = sysctl(Mib, __arraycount(Mib), VmMap, &Size, NULL, 0);
++  CHECK_EQ(Err, 0);
++
++  proc_maps->data = (char*)VmMap;
++  proc_maps->mmaped_size = MmapedSize;
++  proc_maps->len = Size;
++}
++
++bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
++                               char filename[], uptr filename_size,
++                               uptr *protection) {
++  char *last = proc_self_maps_.data + proc_self_maps_.len;
++  if (current_ >= last) return false;
++  uptr dummy;
++  if (!start) start = &dummy;
++  if (!end) end = &dummy;
++  if (!offset) offset = &dummy;
++  if (!protection) protection = &dummy;
++  struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry*)current_;
++
++  *start = (uptr)VmEntry->kve_start;
++  *end = (uptr)VmEntry->kve_end;
++  *offset = (uptr)VmEntry->kve_offset;
++
++  *protection = 0;
++  if ((VmEntry->kve_protection & KVME_PROT_READ) != 0)
++    *protection |= kProtectionRead;
++  if ((VmEntry->kve_protection & KVME_PROT_WRITE) != 0)
++    *protection |= kProtectionWrite;
++  if ((VmEntry->kve_protection & KVME_PROT_EXEC) != 0)
++    *protection |= kProtectionExecute;
++
++  if (filename != NULL && filename_size > 0) {
++    internal_snprintf(filename,
++                      Min(filename_size, (uptr)PATH_MAX),
++                      "%s", VmEntry->kve_path);
++  }
++
++  current_ += sizeof(*VmEntry);
++
++  return true;
++}
++
++}  // namespace __sanitizer
++
++#endif  // SANITIZER_NETBSD


Home | Main Index | Thread Index | Old Index