Skip to content

Commit c80d349

Browse files
committed
[msan][tsan] Refine __fxstat{,at}{,64} condition
In glibc before 2.33, include/sys/stat.h defines fstat/fstat64 to `__fxstat/__fxstat64` and provides `__fxstat/__fxstat64` in libc_nonshared.a. The symbols are glibc specific and not needed on other systems. Reviewed By: vitalybuka, #sanitizers Differential Revision: https://reviews.llvm.org/D118423
1 parent 5d089d9 commit c80d349

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler-rt/lib/msan/msan_interceptors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ INTERCEPTOR(int, fstat, int fd, void *buf) {
666666
#define MSAN_MAYBE_INTERCEPT_FSTAT
667667
#endif
668668

669-
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
669+
#if SANITIZER_GLIBC
670670
INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) {
671671
ENSURE_MSAN_INITED();
672672
int res = REAL(__fxstat)(magic, fd, buf);
@@ -679,7 +679,7 @@ INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) {
679679
#define MSAN_MAYBE_INTERCEPT___FXSTAT
680680
#endif
681681

682-
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
682+
#if SANITIZER_GLIBC
683683
INTERCEPTOR(int, __fxstat64, int magic, int fd, void *buf) {
684684
ENSURE_MSAN_INITED();
685685
int res = REAL(__fxstat64)(magic, fd, buf);
@@ -704,7 +704,7 @@ INTERCEPTOR(int, fstatat, int fd, char *pathname, void *buf, int flags) {
704704
# define MSAN_MAYBE_INTERCEPT_FSTATAT
705705
#endif
706706

707-
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
707+
#if SANITIZER_GLIBC
708708
INTERCEPTOR(int, __fxstatat, int magic, int fd, char *pathname, void *buf,
709709
int flags) {
710710
ENSURE_MSAN_INITED();
@@ -717,7 +717,7 @@ INTERCEPTOR(int, __fxstatat, int magic, int fd, char *pathname, void *buf,
717717
# define MSAN_MAYBE_INTERCEPT___FXSTATAT
718718
#endif
719719

720-
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
720+
#if SANITIZER_GLIBC
721721
INTERCEPTOR(int, __fxstatat64, int magic, int fd, char *pathname, void *buf,
722722
int flags) {
723723
ENSURE_MSAN_INITED();

compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ TSAN_INTERCEPTOR(int, pthread_once, void *o, void (*f)()) {
15361536
return 0;
15371537
}
15381538

1539-
#if SANITIZER_LINUX && !SANITIZER_ANDROID
1539+
#if SANITIZER_GLIBC
15401540
TSAN_INTERCEPTOR(int, __fxstat, int version, int fd, void *buf) {
15411541
SCOPED_TSAN_INTERCEPTOR(__fxstat, version, fd, buf);
15421542
if (fd > 0)
@@ -1562,7 +1562,7 @@ TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
15621562
#endif
15631563
}
15641564

1565-
#if SANITIZER_LINUX && !SANITIZER_ANDROID
1565+
#if SANITIZER_GLIBC
15661566
TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) {
15671567
SCOPED_TSAN_INTERCEPTOR(__fxstat64, version, fd, buf);
15681568
if (fd > 0)
@@ -1574,7 +1574,7 @@ TSAN_INTERCEPTOR(int, __fxstat64, int version, int fd, void *buf) {
15741574
#define TSAN_MAYBE_INTERCEPT___FXSTAT64
15751575
#endif
15761576

1577-
#if SANITIZER_LINUX && !SANITIZER_ANDROID
1577+
#if SANITIZER_GLIBC
15781578
TSAN_INTERCEPTOR(int, fstat64, int fd, void *buf) {
15791579
SCOPED_TSAN_INTERCEPTOR(__fxstat64, 0, fd, buf);
15801580
if (fd > 0)

0 commit comments

Comments
 (0)