[compiler-rt] c6b12bc - Revert "[compiler-rt] intercept macOs's freadlink call. (#83679)"

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 06:21:51 PDT 2024


Author: Hans Wennborg
Date: 2024-10-02T15:21:25+02:00
New Revision: c6b12bc829c863a47f813503fa35f8567ce3ad12

URL: https://github.com/llvm/llvm-project/commit/c6b12bc829c863a47f813503fa35f8567ce3ad12
DIFF: https://github.com/llvm/llvm-project/commit/c6b12bc829c863a47f813503fa35f8567ce3ad12.diff

LOG: Revert "[compiler-rt] intercept macOs's freadlink call. (#83679)"

The lit test has been failing on green dragon since it landed,
e.g. https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/2276/testReport/

This reverts commit a6ea0b0d2973d3d94f9ed7aac6db9ca722664774 and
follow-up commits ce72c76e9bd0bf74af614cae6a9f85cfd4720e95,
a280275cff497f96492d7c1094ba30309dbd3ad6, and
d705bd25eb9f11e100d3e79b65a80d446fd06f30.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Removed: 
    compiler-rt/test/sanitizer_common/TestCases/Darwin/freadlink.c


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 139c80b4f4a533..d3c41221d5a94c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -10350,24 +10350,6 @@ INTERCEPTOR(SSIZE_T, pwritev2, int fd, __sanitizer_iovec *iov, int iovcnt,
 #define INIT_PWRITEV2
 #endif
 
-#if SANITIZER_INTERCEPT_FREADLINK
-INTERCEPTOR(SSIZE_T, freadlink, int fd, char *buf, SIZE_T bufsiz) {
-  void *ctx;
-  COMMON_INTERCEPTOR_ENTER(ctx, freadlink, fd, buf, bufsiz);
-  COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
-  SSIZE_T res = REAL(freadlink)(fd, buf, bufsiz);
-  if (res > 0)
-    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, res);
-  if (res >= 0 && fd > 0)
-    COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
-  return res;
-}
-
-#  define INIT_FREADLINK COMMON_INTERCEPT_FUNCTION(freadlink)
-#else
-#  define INIT_FREADLINK
-#endif
-
 #include "sanitizer_common_interceptors_netbsd_compat.inc"
 
 namespace __sanitizer {
@@ -10689,7 +10671,6 @@ static void InitializeCommonInterceptors() {
   INIT_CPUSET_GETAFFINITY;
   INIT_PREADV2;
   INIT_PWRITEV2;
-  INIT_FREADLINK;
 
   INIT___PRINTF_CHK;
 }

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 272e4a02e6a7fe..b1dc1ec204bc8c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -607,13 +607,6 @@
 // FIXME: also available from musl 1.2.5
 #define SANITIZER_INTERCEPT_PREADV2 (SI_LINUX && __GLIBC_PREREQ(2, 26))
 #define SANITIZER_INTERCEPT_PWRITEV2 (SI_LINUX && __GLIBC_PREREQ(2, 26))
-#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
-    __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000
-#  define SI_MAC_OS_DEPLOYMENT_MIN_13_00 1
-#else
-#  define SI_MAC_OS_DEPLOYMENT_MIN_13_00 0
-#endif
-#define SANITIZER_INTERCEPT_FREADLINK (SI_MAC && SI_MAC_OS_DEPLOYMENT_MIN_13_00)
 
 // This macro gives a way for downstream users to override the above
 // interceptor macros irrespective of the platform they are on. They have

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Darwin/freadlink.c b/compiler-rt/test/sanitizer_common/TestCases/Darwin/freadlink.c
deleted file mode 100644
index e67a07a597bbc5..00000000000000
--- a/compiler-rt/test/sanitizer_common/TestCases/Darwin/freadlink.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clang -O0 %s -o %t && %run %t
-//
-// This test fails under x86_64, freadlink can't read the current symlink path.
-// XFAIL: x86_64-darwin
-
-#include <assert.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-int main(int argc, char **argv) {
-  char symlink_path[PATH_MAX];
-  snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
-           getpid());
-  remove(symlink_path);
-  int res = symlink(argv[0], symlink_path);
-  assert(!res);
-
-  int fd;
-  char readlink_path[PATH_MAX];
-  fd = open(symlink_path, O_RDONLY);
-  ssize_t res2 = freadlink(fd, readlink_path, sizeof(readlink_path));
-  assert(res2 >= 0);
-  readlink_path[res2] = '\0';
-  assert(!strcmp(readlink_path, argv[0]));
-  close(fd);
-
-  return 0;
-}


        


More information about the llvm-commits mailing list