lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 18.09-beta 370 lines 15 kB view raw
1From 3e1fcb7d4909db8f0f7dd0109b2eee20115c8be3 Mon Sep 17 00:00:00 2001 2From: "Jory A. Pratt" <anarchy@gentoo.org> 3Date: Sat, 9 Sep 2017 08:31:15 -0500 4Subject: [PATCH] Ported to compiler-rt-sanitizers-5.0.0. Taken from 5 6https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch 7Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> 8 9Taken from gentoo-musl project, with a few additional minor fixes. 10--- 11 lib/asan/asan_linux.cc | 4 +-- 12 lib/interception/interception_linux.cc | 2 +- 13 lib/interception/interception_linux.h | 2 +- 14 lib/msan/msan_linux.cc | 2 +- 15 .../sanitizer_common_interceptors_ioctl.inc | 4 +-- 16 lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +- 17 lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 +++---- 18 lib/sanitizer_common/sanitizer_platform.h | 7 ++++ 19 .../sanitizer_platform_interceptors.h | 2 +- 20 .../sanitizer_platform_limits_posix.cc | 40 +++++++++++++--------- 21 lib/tsan/rtl/tsan_platform_linux.cc | 2 +- 22 11 files changed, 47 insertions(+), 32 deletions(-) 23 24diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc 25index 6d47ba432..c58dd4864 100644 26--- a/lib/asan/asan_linux.cc 27+++ b/lib/asan/asan_linux.cc 28@@ -39,7 +39,7 @@ 29 #include <sys/link_elf.h> 30 #endif 31 32-#if SANITIZER_ANDROID || SANITIZER_FREEBSD 33+#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU 34 #include <ucontext.h> 35 extern "C" void* _DYNAMIC; 36 #else 37@@ -86,7 +86,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { 38 UNIMPLEMENTED(); 39 } 40 41-#if SANITIZER_ANDROID 42+#if SANITIZER_ANDROID || SANITIZER_NONGNU 43 // FIXME: should we do anything for Android? 44 void AsanCheckDynamicRTPrereqs() {} 45 void AsanCheckIncompatibleRT() {} 46diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc 47index 6e908ac01..76c1688ce 100644 48--- a/lib/interception/interception_linux.cc 49+++ b/lib/interception/interception_linux.cc 50@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, 51 return real == wrapper; 52 } 53 54-#if !defined(__ANDROID__) // android does not have dlvsym 55+#if !defined(__ANDROID__) && defined(__GLIBC__) // android does not have dlvsym 56 void *GetFuncAddrVer(const char *func_name, const char *ver) { 57 return dlvsym(RTLD_NEXT, func_name, ver); 58 } 59diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h 60index 27a66c882..f60c38991 100644 61--- a/lib/interception/interception_linux.h 62+++ b/lib/interception/interception_linux.h 63@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); 64 (::__interception::uptr) & (func), \ 65 (::__interception::uptr) & WRAP(func)) 66 67-#if !defined(__ANDROID__) // android does not have dlvsym 68+#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym 69 #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ 70 (::__interception::real_##func = (func##_f)( \ 71 unsigned long)::__interception::GetFuncAddrVer(#func, symver)) 72diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc 73index 0a687f620..0852d97d7 100644 74--- a/lib/msan/msan_linux.cc 75+++ b/lib/msan/msan_linux.cc 76@@ -13,7 +13,7 @@ 77 //===----------------------------------------------------------------------===// 78 79 #include "sanitizer_common/sanitizer_platform.h" 80-#if SANITIZER_FREEBSD || SANITIZER_LINUX 81+#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU 82 83 #include "msan.h" 84 #include "msan_thread.h" 85diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 86index 4ed9afedf..64f584e93 100644 87--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 88+++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc 89@@ -100,7 +100,7 @@ static void ioctl_table_fill() { 90 _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); 91 #endif 92 93-#if SANITIZER_LINUX 94+#if SANITIZER_LINUX && !SANITIZER_NONGNU 95 // Conflicting request ids. 96 // _(CDROMAUDIOBUFSIZ, NONE, 0); 97 // _(SNDCTL_TMR_CONTINUE, NONE, 0); 98@@ -361,7 +361,7 @@ static void ioctl_table_fill() { 99 _(VT_WAITACTIVE, NONE, 0); 100 #endif 101 102-#if SANITIZER_LINUX && !SANITIZER_ANDROID 103+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 104 // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE 105 _(CYGETDEFTHRESH, WRITE, sizeof(int)); 106 _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); 107diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc 108index 469c8eb7e..24f87867d 100644 109--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc 110+++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc 111@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { 112 } 113 } 114 115-#if !SANITIZER_ANDROID 116+#if !SANITIZER_ANDROID && !SANITIZER_NONGNU 117 PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, 118 void *old_rlim) { 119 if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); 120diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 121index 52196db12..045d9331f 100644 122--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc 123+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc 124@@ -148,7 +148,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { 125 #endif 126 } 127 128-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO 129+#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU 130 static uptr g_tls_size; 131 132 #ifdef __i386__ 133@@ -176,11 +176,11 @@ void InitTlsSize() { 134 } 135 #else 136 void InitTlsSize() { } 137-#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO 138+#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU 139 140 #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ 141 || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \ 142- || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID 143+ || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 144 // sizeof(struct pthread) from glibc. 145 static atomic_uintptr_t kThreadDescriptorSize; 146 147@@ -335,7 +335,7 @@ uptr ThreadSelf() { 148 149 #if !SANITIZER_GO 150 static void GetTls(uptr *addr, uptr *size) { 151-#if SANITIZER_LINUX && !SANITIZER_ANDROID 152+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 153 # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) 154 *addr = ThreadSelf(); 155 *size = GetTlsSize(); 156@@ -362,7 +362,7 @@ static void GetTls(uptr *addr, uptr *size) { 157 *addr = (uptr) dtv[2]; 158 *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]); 159 } 160-#elif SANITIZER_ANDROID 161+#elif SANITIZER_ANDROID || SANITIZER_NONGNU 162 *addr = 0; 163 *size = 0; 164 #else 165@@ -373,7 +373,7 @@ static void GetTls(uptr *addr, uptr *size) { 166 167 #if !SANITIZER_GO 168 uptr GetTlsSize() { 169-#if SANITIZER_FREEBSD || SANITIZER_ANDROID 170+#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU 171 uptr addr, size; 172 GetTls(&addr, &size); 173 return size; 174diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h 175index 396f7c934..5af6f1ed5 100644 176--- a/lib/sanitizer_common/sanitizer_platform.h 177+++ b/lib/sanitizer_common/sanitizer_platform.h 178@@ -175,6 +175,13 @@ 179 # define SANITIZER_ARM 0 180 #endif 181 182+ 183+#if defined(__linux__) && !defined(__GLIBC__) 184+# define SANITIZER_NONGNU 1 185+#else 186+# define SANITIZER_NONGNU 0 187+#endif 188+ 189 // By default we allow to use SizeClassAllocator64 on 64-bit platform. 190 // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 191 // does not work well and we need to fallback to SizeClassAllocator32. 192diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h 193index 0380cee92..0a39abbd0 100644 194--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h 195+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h 196@@ -31,7 +31,7 @@ 197 # define SI_POSIX 0 198 #endif 199 200-#if SANITIZER_LINUX && !SANITIZER_ANDROID 201+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 202 # define SI_LINUX_NOT_ANDROID 1 203 #else 204 # define SI_LINUX_NOT_ANDROID 0 205diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 206index 83f4fd22f..fa8c1b8bd 100644 207--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 208+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc 209@@ -14,6 +14,9 @@ 210 211 #include "sanitizer_platform.h" 212 213+// Workaround musl <--> linux conflicting definition of 'struct sysinfo' 214+#define _LINUX_SYSINFO_H 215+ 216 #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC 217 // Tests in this file assume that off_t-dependent data structures match the 218 // libc ABI. For example, struct dirent here is what readdir() function (as 219@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; 220 221 #if SANITIZER_LINUX && !SANITIZER_ANDROID 222 #include <glob.h> 223-#include <obstack.h> 224+# if !SANITIZER_NONGNU 225+# include <obstack.h> 226+# endif 227 #include <mqueue.h> 228-#include <net/if_ppp.h> 229-#include <netax25/ax25.h> 230-#include <netipx/ipx.h> 231-#include <netrom/netrom.h> 232+#include <linux/if_ppp.h> 233+#include <linux/ax25.h> 234+#include <linux/ipx.h> 235+#include <linux/netrom.h> 236 #if HAVE_RPC_XDR_H 237 # include <rpc/xdr.h> 238 #elif HAVE_TIRPC_RPC_XDR_H 239@@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t; 240 # include <sys/procfs.h> 241 #endif 242 #include <sys/user.h> 243-#include <sys/ustat.h> 244+// #include <sys/ustat.h> 245+#include <sys/statfs.h> 246 #include <linux/cyclades.h> 247 #include <linux/if_eql.h> 248 #include <linux/if_plip.h> 249@@ -251,7 +257,7 @@ namespace __sanitizer { 250 unsigned struct_itimerspec_sz = sizeof(struct itimerspec); 251 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 252 253-#if SANITIZER_LINUX && !SANITIZER_ANDROID 254+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 255 unsigned struct_ustat_sz = sizeof(struct ustat); 256 unsigned struct_rlimit64_sz = sizeof(struct rlimit64); 257 unsigned struct_statvfs64_sz = sizeof(struct statvfs64); 258@@ -309,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); 259 unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 260 #endif 261 262-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 263+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 264 int glob_nomatch = GLOB_NOMATCH; 265 int glob_altdirfunc = GLOB_ALTDIRFUNC; 266 #endif 267@@ -403,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 268 unsigned struct_termios_sz = sizeof(struct termios); 269 unsigned struct_winsize_sz = sizeof(struct winsize); 270 271-#if SANITIZER_LINUX 272+#if SANITIZER_LINUX && !SANITIZER_NONGNU 273 unsigned struct_arpreq_sz = sizeof(struct arpreq); 274 unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); 275 unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); 276@@ -453,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 277 unsigned struct_vt_mode_sz = sizeof(struct vt_mode); 278 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 279 280-#if SANITIZER_LINUX && !SANITIZER_ANDROID 281+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 282 unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); 283 unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); 284 #if EV_VERSION > (0x010000) 285@@ -821,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); 286 unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; 287 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 288 289-#if SANITIZER_LINUX && !SANITIZER_ANDROID 290+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 291 unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; 292 unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; 293 unsigned IOCTL_CYGETMON = CYGETMON; 294@@ -976,7 +982,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); 295 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); 296 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD 297 298-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 299+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 300 CHECK_TYPE_SIZE(glob_t); 301 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); 302 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); 303@@ -1010,6 +1016,7 @@ CHECK_TYPE_SIZE(iovec); 304 CHECK_SIZE_AND_OFFSET(iovec, iov_base); 305 CHECK_SIZE_AND_OFFSET(iovec, iov_len); 306 307+#if !SANITIZER_NONGNU 308 CHECK_TYPE_SIZE(msghdr); 309 CHECK_SIZE_AND_OFFSET(msghdr, msg_name); 310 CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); 311@@ -1023,6 +1030,7 @@ CHECK_TYPE_SIZE(cmsghdr); 312 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); 313 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); 314 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); 315+#endif 316 317 COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); 318 CHECK_SIZE_AND_OFFSET(dirent, d_ino); 319@@ -1125,7 +1133,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); 320 321 CHECK_TYPE_SIZE(ether_addr); 322 323-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID 324+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU 325 CHECK_TYPE_SIZE(ipc_perm); 326 # if SANITIZER_FREEBSD 327 CHECK_SIZE_AND_OFFSET(ipc_perm, key); 328@@ -1186,7 +1194,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); 329 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); 330 #endif 331 332-#if SANITIZER_LINUX 333+#if SANITIZER_LINUX && !SANITIZER_NONGNU 334 COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); 335 #endif 336 337@@ -1236,7 +1244,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); 338 COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); 339 #endif 340 341-#if SANITIZER_LINUX && !SANITIZER_ANDROID 342+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 343 COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); 344 CHECK_SIZE_AND_OFFSET(FILE, _flags); 345 CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); 346@@ -1255,7 +1263,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); 347 CHECK_SIZE_AND_OFFSET(FILE, _fileno); 348 #endif 349 350-#if SANITIZER_LINUX && !SANITIZER_ANDROID 351+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 352 COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); 353 CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); 354 CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); 355diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc 356index ead1e5704..2c020e3fe 100644 357--- a/lib/tsan/rtl/tsan_platform_linux.cc 358+++ b/lib/tsan/rtl/tsan_platform_linux.cc 359@@ -284,7 +284,7 @@ void InitializePlatform() { 360 // This is required to properly "close" the fds, because we do not see internal 361 // closes within glibc. The code is a pure hack. 362 int ExtractResolvFDs(void *state, int *fds, int nfd) { 363-#if SANITIZER_LINUX && !SANITIZER_ANDROID 364+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU 365 int cnt = 0; 366 struct __res_state *statp = (struct __res_state*)state; 367 for (int i = 0; i < MAXNS && cnt < nfd; i++) { 368-- 3692.16.2 370