brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 872848d Raw
44 lines · cpp
1// Check that when launching with DYLD_INSERT_LIBRARIES, we properly remove2// the ASan dylib from the environment variable (both when using an absolute3// or relative path) and also that the other dylibs are left untouched.4 5// UNSUPPORTED: ios6 7// RUN: rm -rf %t && mkdir -p %t8// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name9// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \10// RUN:   %t/libclang_rt.asan_osx_dynamic.dylib11 12// RUN: %clangxx_asan %s -o %t/a.out13// RUN: %clangxx -DSHARED_LIB %s \14// RUN:     -dynamiclib -o %t/dummy-so.dylib15 16// RUN: cd %t17// RUN: env DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \18// RUN: %run ./a.out 2>&1 | FileCheck %s19 20// RUN: env DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \21// RUN: %run ./a.out 2>&1 | FileCheck %s22 23// RUN: %env_asan_opts=strip_env=0 \24// RUN: DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \25// RUN: %run ./a.out 2>&1 | FileCheck %s --check-prefix=CHECK-KEEP26 27// RUN: env DYLD_INSERT_LIBRARIES=%t/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \28// RUN: %run ./a.out 2>&1 | FileCheck %s29 30#if !defined(SHARED_LIB)31#include <stdio.h>32#include <stdlib.h>33 34int main() {35  const char kEnvName[] = "DYLD_INSERT_LIBRARIES";36  printf("%s=%s\n", kEnvName, getenv(kEnvName));37  // CHECK: {{DYLD_INSERT_LIBRARIES=dummy-so.dylib}}38  // CHECK-KEEP: {{DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib}}39  return 0;40}41#else  // SHARED_LIB42void foo() {}43#endif  // SHARED_LIB44