1 // Test for ASAN_OPTIONS=start_deactivated=1 mode.
2 // Main executable is uninstrumented, but linked to ASan runtime. The shared
3 // library is instrumented.
4 // Fails with debug checks: https://bugs.llvm.org/show_bug.cgi?id=46862
5 // XFAIL: !compiler-rt-optimized
7 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
8 // RUN: %clangxx -O0 %s -c -o %t.o
9 // RUN: %clangxx_asan -O0 %t.o %libdl -o %t
11 // RUN: rm -f %t.asan.options.activation-options.cpp.tmp
12 // RUN: rm -f %t.asan.options.ABCDE
13 // RUN: echo "help=1" >%t.asan.options.activation-options.cpp.tmp
15 // RUN: %env_asan_opts=start_deactivated=1 \
16 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b %run %t 2>&1 | \
17 // RUN: FileCheck %s --check-prefix=CHECK-HELP --check-prefix=CHECK-FOUND
19 // RUN: %env_asan_opts=start_deactivated=1 \
20 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options not %run %t 2>&1 | \
21 // RUN: FileCheck %s --check-prefix=CHECK-NO-HELP --check-prefix=CHECK-MISSING
23 // RUN: %env_asan_opts=start_deactivated=1 \
24 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b not %run %t --fix-name 2>&1 | \
25 // RUN: FileCheck %s --check-prefix=CHECK-NO-HELP --check-prefix=CHECK-MISSING
27 // RUN: echo "help=1" >%t.asan.options.ABCDE
29 // RUN: %env_asan_opts=start_deactivated=1 \
30 // RUN: ASAN_ACTIVATION_OPTIONS=include=%t.asan.options.%b %run %t --fix-name 2>&1 | \
31 // RUN: FileCheck %s --check-prefix=CHECK-HELP --check-prefix=CHECK-FOUND
35 #if !defined(SHARED_LIB)
45 #include "sanitizer/asan_interface.h"
49 int main(int argc
, char *argv
[]) {
50 std::string path
= std::string(argv
[0]) + "-so.so";
52 if (argc
> 1 && strcmp(argv
[1], "--fix-name") == 0) {
53 assert(strlen(argv
[0]) > 5);
54 strcpy(argv
[0], "ABCDE");
57 void *dso
= dlopen(path
.c_str(), RTLD_NOW
);
59 fprintf(stderr
, "dlopen failed: %s\n", dlerror());
66 // Empty: all we need is an ASan shared library constructor.
69 // CHECK-HELP: Available flags for {{.*}}Sanitizer:
70 // CHECK-NO-HELP-NOT: Available flags for {{.*}}Sanitizer:
71 // CHECK-FOUND-NOT: Failed to read options
72 // CHECK-MISSING: Failed to read options