OSDN Git Service

[compiler-rt] fix build on Illumos
authorDavid Carlier <devnexen@gmail.com>
Wed, 22 Jul 2020 14:15:45 +0000 (15:15 +0100)
committerDavid Carlier <devnexen@gmail.com>
Wed, 22 Jul 2020 14:19:56 +0000 (15:19 +0100)
- 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

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_solaris.cpp
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_procmaps_solaris.cpp

index 6ec1a1b..565b31f 100644 (file)
@@ -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);
index f920172..0bd64dd 100644 (file)
 #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 {
index 8793423..4063ec8 100644 (file)
@@ -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<prxmap_t *>(reinterpret_cast<const prxmap_t *>(data_.current));
 
   segment->start = (uptr)xmapentry->pr_vaddr;
   segment->end = (uptr)(xmapentry->pr_vaddr + xmapentry->pr_size);