Index: compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -7777,9 +7777,18 @@ COMMON_INTERCEPTOR_READ_RANGE(ctx, preg, struct_regex_sz); REAL(regfree)(preg); } + +#ifdef SANITIZER_REGEXEC_VERSION +#define COMMON_INTERCEPT_FUNCTION_REGEXEC(fn) \ + COMMON_INTERCEPT_FUNCTION_VER(fn, SANITIZER_REGEXEC_VERSION) +#else +#define COMMON_INTERCEPT_FUNCTION_REGEXEC(fn) \ + COMMON_INTERCEPT_FUNCTION(fn) +#endif + #define INIT_REGEX \ COMMON_INTERCEPT_FUNCTION(regcomp); \ - COMMON_INTERCEPT_FUNCTION(regexec); \ + COMMON_INTERCEPT_FUNCTION_REGEXEC(regexec); \ COMMON_INTERCEPT_FUNCTION(regerror); \ COMMON_INTERCEPT_FUNCTION(regfree); #else Index: compiler-rt/lib/sanitizer_common/sanitizer_platform.h =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_platform.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -139,6 +139,12 @@ # define SANITIZER_X32 0 #endif +#if defined(__x86_64__) && defined(_LP64) +# define SANITIZER_X86_64 1 +#else +# define SANITIZER_X86_64 0 +#endif + #if defined(__i386__) || defined(_M_IX86) # define SANITIZER_I386 1 #else @@ -232,6 +238,12 @@ #define SANITIZER_RISCV64 0 #endif +#if defined(__sparc__) +#define SANITIZER_SPARC 1 +#else +#define SANITIZER_SPARC 0 +#endif + // By default we allow to use SizeClassAllocator64 on 64-bit platform. // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 // does not work well and we need to fallback to SizeClassAllocator32. @@ -265,7 +277,7 @@ # else # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48) # endif -#elif defined(__sparc__) +#elif defined(SANITIZER_SPARC) #define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 52) #else # define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47) @@ -274,7 +286,7 @@ // Whether the addresses are sign-extended from the VMA range to the word. // The SPARC64 Linux port implements this to split the VMA space into two // non-contiguous halves with a huge hole in the middle. -#if defined(__sparc__) && SANITIZER_WORDSIZE == 64 +#if defined(SANITIZER_SPARC) && SANITIZER_WORDSIZE == 64 #define SANITIZER_SIGN_EXTENDED_ADDRESSES 1 #else #define SANITIZER_SIGN_EXTENDED_ADDRESSES 0 @@ -298,7 +310,7 @@ // built against > linux-2.2 kernel headers // Since we don't want to include libc headers here, we check the // target only. -#if defined(__arm__) || SANITIZER_X32 || defined(__sparc__) +#if defined(__arm__) || SANITIZER_X32 || defined(SANITIZER_SPARC) #define SANITIZER_USES_UID16_SYSCALLS 1 #else #define SANITIZER_USES_UID16_SYSCALLS 0 @@ -335,6 +347,14 @@ #define SANITIZER_NLDBL_VERSION "GLIBC_2.4" #endif +// On linux, we need a recent regexec implementation that supports +// a non-POSIX flag REG_STARTEND. Target that are younger than GLIBC_2.3.4 +// can use a default (non-versioned) symbol. +#if SANITIZER_LINUX && (SANITIZER_MIPS || SANITIZER_S390 || SANITIZER_SPARC \ + || SANITIZER_PPC32 || SANITIZER_PPC64V1 || SANITIZER_X86_64) +#define SANITIZER_REGEXEC_VERSION "GLIBC_2.3.4" +#endif + #if SANITIZER_GO == 0 # define SANITIZER_GO 0 #endif