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