1 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \ 2 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \ 3 // RUN: -fsanitize=hwaddress -emit-llvm -o - %s | FileCheck %s 4 5 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \ 6 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \ 7 // RUN: -fsanitize=hwaddress -emit-llvm -o - %s | \ 8 // RUN: FileCheck %s --check-prefix=IGNORELIST 9 10 int global; 11 int __attribute__((no_sanitize("hwaddress"))) attributed_global; 12 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global; 13 int ignorelisted_global; 14 15 void func() { 16 static int static_var = 0; 17 const char *literal = "Hello, world!"; 18 } 19 20 // CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 21 // CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 22 // CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 23 // CHECK: @{{.*}}extra_global{{.*}}.hwasan{{.*}} = 24 // CHECK: @{{.*}}global{{.*}}.hwasan{{.*}} = 25 // CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} = 26 // CHECK: @{{.*}}.hwasan{{.*}} = {{.*}} c"Hello, world!\00" 27 28 // CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]} 29 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false} 30 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5} 31 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false} 32 // CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 10, i32 5} 33 // CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true} 34 // CHECK: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true} 35 // CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true} 36 // CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 false, i1 false} 37 // CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 16, i32 14} 38 // CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"<string literal>", i1 false, i1 false} 39 // CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 17, i32 25} 40 41 // IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 42 // IGNORELIST: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 43 // IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 44 // IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 45 // IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress 46 // IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_hwaddress 47 // IGNORELIST: @{{.*}}extra_global{{.*}}.hwasan{{.*}} = 48 49 // IGNORELIST: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]} 50 // IGNORELIST: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false} 51 // IGNORELIST: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5} 52 // IGNORELIST: ![[GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true} 53 // IGNORELIST: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true} 54 // IGNORELIST: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true} 55 // IGNORELIST: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true} 56 // IGNORELIST: ![[STATIC_VAR]] = !{{{.*}} null, null, i1 false, i1 true} 57 // IGNORELIST: ![[LITERAL]] = !{{{.*}} null, null, i1 false, i1 true} 58