From c61dcb8f623e5d289164f44c086867d0b052b1e5 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 22 Jul 2020 15:15:45 +0100 Subject: [PATCH] [compiler-rt] fix build on Illumos - there are additional fields for glob_t struct, thus size check is failing. - to access old mman.h api based on caddr_t, _XOPEN_SOURCE needs to be not defined thus we provide the prototype. - prxmap_t constified. Reviewers: ro, eugenis Reviewed-By: ro Differential Revision: https://reviews.llvm.org/D84046 --- .../sanitizer_common/sanitizer_platform_limits_solaris.cpp | 3 ++- .../lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 6 ++++++ .../lib/sanitizer_common/sanitizer_procmaps_solaris.cpp | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp index 6ec1a1bdd114..565b31f68aae 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp @@ -202,7 +202,8 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); -CHECK_TYPE_SIZE(glob_t); +// There are additional fields we are not interested in. +COMPILER_CHECK(sizeof(__sanitizer_glob_t) <= sizeof(glob_t)); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); CHECK_SIZE_AND_OFFSET(glob_t, gl_offs); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index f920172c06d6..0bd64dd0d3e9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -44,6 +44,12 @@ #define MAP_NORESERVE 0 #endif +#if SANITIZER_SOLARIS +// Illumos' declaration of madvie cannot be made visible if _XOPEN_SOURCE +// is defined as g++ does on Solaris. +extern "C" int madvise(caddr_t, size_t, int); +#endif + typedef void (*sa_sigaction_t)(int, siginfo_t *, void *); namespace __sanitizer { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp index 8793423a6017..4063ec8deaa1 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp @@ -35,7 +35,8 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) { char *last = data_.proc_self_maps.data + data_.proc_self_maps.len; if (data_.current >= last) return false; - prxmap_t *xmapentry = (prxmap_t*)data_.current; + prxmap_t *xmapentry = + const_cast(reinterpret_cast(data_.current)); segment->start = (uptr)xmapentry->pr_vaddr; segment->end = (uptr)(xmapentry->pr_vaddr + xmapentry->pr_size);