diff options
| author | Kamil Rytarowski <n54@gmx.com> | 2017-08-10 18:51:51 +0000 | 
|---|---|---|
| committer | Kamil Rytarowski <n54@gmx.com> | 2017-08-10 18:51:51 +0000 | 
| commit | 4ad374ea76d2bd57bf5a27f945ca72828bcc6f7b (patch) | |
| tree | 35bfbf72b484d4c328abfe88bfe16a555e64ff21 /compiler-rt | |
| parent | fbd51b954da5626d8aec17cfaa38bfa66600628a (diff) | |
| download | bcm5719-llvm-4ad374ea76d2bd57bf5a27f945ca72828bcc6f7b.tar.gz bcm5719-llvm-4ad374ea76d2bd57bf5a27f945ca72828bcc6f7b.zip | |
Add NetBSD support in asan_linux.cc
Summary:
Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.
Sponsored by <The NetBSD Foundation>
Reviewers: fjricci, vitalybuka, joerg, kcc, filcab
Reviewed By: vitalybuka
Subscribers: llvm-commits, kubamracek, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D36488
llvm-svn: 310647
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/asan/asan_linux.cc | 17 | 
1 files changed, 15 insertions, 2 deletions
| diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc index 6d47ba432a6..9ebfea2542b 100644 --- a/compiler-rt/lib/asan/asan_linux.cc +++ b/compiler-rt/lib/asan/asan_linux.cc @@ -13,7 +13,7 @@  //===----------------------------------------------------------------------===//  #include "sanitizer_common/sanitizer_platform.h" -#if SANITIZER_FREEBSD || SANITIZER_LINUX +#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD  #include "asan_interceptors.h"  #include "asan_internal.h" @@ -42,6 +42,10 @@  #if SANITIZER_ANDROID || SANITIZER_FREEBSD  #include <ucontext.h>  extern "C" void* _DYNAMIC; +#elif SANITIZER_NETBSD +#include <link_elf.h> +#include <ucontext.h> +extern Elf_Dyn _DYNAMIC;  #else  #include <sys/ucontext.h>  #include <link.h> @@ -101,6 +105,15 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,    if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)      return 0; +#if SANITIZER_NETBSD +  // Ignore first entry (the main program) +  char **p = (char **)data; +  if (!(*p)) { +    *p = (char *)-1; +    return 0; +  } +#endif +    *(const char **)data = info->dlpi_name;    return 1;  } @@ -179,4 +192,4 @@ void *AsanDlSymNext(const char *sym) {  } // namespace __asan -#endif // SANITIZER_FREEBSD || SANITIZER_LINUX +#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD | 

