Home | History | Annotate | Download | only in Darwin
      1 // When DYLD-inserting the ASan dylib from a different location than the
      2 // original, make sure we don't try to reexec.
      3 
      4 // RUN: mkdir -p %T/dyld_insert_libraries_reexec
      5 // RUN: cp `%clang_asan %s -fsanitize=address -### 2>&1 \
      6 // RUN:   | grep "libclang_rt.asan_osx_dynamic.dylib" \
      7 // RUN:   | sed -e 's/.*"\(.*libclang_rt.asan_osx_dynamic.dylib\)".*/\1/'` \
      8 // RUN:   %T/dyld_insert_libraries_reexec/libclang_rt.asan_osx_dynamic.dylib
      9 // RUN: %clangxx_asan %s -o %T/dyld_insert_libraries_reexec/a.out
     10 
     11 // RUN:   %env_asan_opts=verbosity=1 \
     12 // RUN:       DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib \
     13 // RUN:       %run %T/dyld_insert_libraries_reexec/a.out 2>&1 \
     14 // RUN:   | FileCheck %s
     15 
     16 // RUN: IS_OSX_10_11_OR_HIGHER=$([ `sw_vers -productVersion | cut -d'.' -f2` -lt 11 ]; echo $?)
     17 
     18 // On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec.
     19 // RUN: if [ $IS_OSX_10_11_OR_HIGHER == 0 ]; then \
     20 // RUN:   %env_asan_opts=verbosity=1 %run %T/dyld_insert_libraries_reexec/a.out 2>&1 \
     21 // RUN:   | FileCheck --check-prefix=CHECK-NOINSERT %s; \
     22 // RUN:   fi
     23 
     24 // On OS X 10.11 and higher, we don't need to DYLD-insert anymore, and the interceptors
     25 // still installed correctly. Let's just check that things work and we don't try to re-exec.
     26 // RUN: if [ $IS_OSX_10_11_OR_HIGHER == 1 ]; then \
     27 // RUN:   %env_asan_opts=verbosity=1 %run %T/dyld_insert_libraries_reexec/a.out 2>&1 \
     28 // RUN:   | FileCheck %s; \
     29 // RUN:   fi
     30 
     31 #include <stdio.h>
     32 
     33 int main() {
     34   printf("Passed\n");
     35   return 0;
     36 }
     37 
     38 // CHECK-NOINSERT: exec()-ing the program with
     39 // CHECK-NOINSERT: DYLD_INSERT_LIBRARIES
     40 // CHECK-NOINSERT: to enable wrappers.
     41 // CHECK-NOINSERT: Passed
     42 
     43 // CHECK-NOT: exec()-ing the program with
     44 // CHECK-NOT: DYLD_INSERT_LIBRARIES
     45 // CHECK-NOT: to enable wrappers.
     46 // CHECK: Passed
     47