[sanitizer] Another try to fix the test with GLIBC 2.34
authorVitaly Buka <vitalybuka@google.com>
Sat, 13 Nov 2021 22:47:27 +0000 (14:47 -0800)
committerVitaly Buka <vitalybuka@google.com>
Sun, 14 Nov 2021 08:32:23 +0000 (00:32 -0800)
compiler-rt/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cpp

index 9853abd..027aca5 100644 (file)
@@ -1,7 +1,6 @@
-// RUN: %clangxx -O2 -ldl %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx -O2 %s -o %t && %run %t 2>&1 | FileCheck %s
 
 #include <stdio.h>
-#include <dlfcn.h>
 
 #if !defined(__GLIBC_PREREQ)
 #define __GLIBC_PREREQ(a, b) 0
 // glbc version 2.16.
 #if __GLIBC_PREREQ(2, 16)
 extern "C" long sysconf(int name) {
-  fprintf(stderr, "sysconf wrapper called\n");
-  auto *addr = (long(*)(int))dlsym(RTLD_NEXT, "sysconf");
-  if (addr)
-    return (*addr)(name);
+  if (name == 158 /*_SC_SIGSTKSZ */) {
+    // Asan calls it during initialization but late enough to succeed.
+    return 0x10000;
+  }
+  fprintf(stderr, "sysconf wrapper called: %d\n", name);
   return 0;
 }
 #endif  // defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 16)