| 1 | // RUN: %clangxx -O2 %s -o %t && %run %t 2>&1 | FileCheck %s |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | #if !defined(__GLIBC_PREREQ) |
| 6 | #define __GLIBC_PREREQ(a, b) 0 |
| 7 | #endif |
| 8 | |
| 9 | // getauxval() used instead of sysconf() in GetPageSize() is defined starting |
| 10 | // glbc version 2.16. |
| 11 | // Does not work with 2.31 and above at it calls sysconf for SIGSTKSZ. |
| 12 | #if __GLIBC_PREREQ(2, 16) && !__GLIBC_PREREQ(2, 31) |
| 13 | extern "C" long sysconf(int name) { |
| 14 | fprintf(stderr, "sysconf wrapper called: %d\n" , name); |
| 15 | return 0; |
| 16 | } |
| 17 | #endif |
| 18 | |
| 19 | int main() { |
| 20 | // All we need to check is that the sysconf() interceptor defined above was |
| 21 | // not called. Should it get called, it will crash right there, any |
| 22 | // instrumented code executed before sanitizer init is finished will crash |
| 23 | // accessing non-initialized sanitizer internals. Even if it will not crash |
| 24 | // in some configuration, it should never be called anyway. |
| 25 | fprintf(stderr, format: "Passed\n" ); |
| 26 | // CHECK-NOT: sysconf wrapper called |
| 27 | // CHECK: Passed |
| 28 | // CHECK-NOT: sysconf wrapper called |
| 29 | return 0; |
| 30 | } |
| 31 | |