| 1 |
// RUN: %clang_cc1 -triple aarch64-linux-android34 \ |
| 2 |
// RUN: -include %S/Inputs/sanitizer-extra-source.cpp \ |
| 3 |
// RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \ |
| 4 |
// RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | FileCheck %s |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -triple aarch64-linux-android34 \ |
| 7 |
// RUN: -include %S/Inputs/sanitizer-extra-source.cpp \ |
| 8 |
// RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \ |
| 9 |
// RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | \ |
| 10 |
// RUN: FileCheck %s --check-prefix=IGNORELIST |
| 11 |
|
| 12 |
int global; |
| 13 |
int __attribute__((__section__("my_section"))) section_global; |
| 14 |
int __attribute__((no_sanitize("memtag"))) attributed_global; |
| 15 |
int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global; |
| 16 |
int ignorelisted_global; |
| 17 |
extern int external_global; |
| 18 |
|
| 19 |
void func() { |
| 20 |
static int static_var = 0; |
| 21 |
const char *literal = "Hello, world!"; |
| 22 |
external_global = 1; |
| 23 |
} |
| 24 |
|
| 25 |
// CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag |
| 26 |
// CHECK: @{{.*}}global{{.*}} ={{.*}} sanitize_memtag |
| 27 |
|
| 28 |
// This DOES NOT mean we are instrumenting the section global, |
| 29 |
// but we are ignoring it in AsmPrinter rather than in clang. |
| 30 |
// CHECK: @{{.*}}section_global{{.*}} ={{.*}} sanitize_memtag |
| 31 |
// CHECK: @{{.*}}attributed_global{{.*}} = |
| 32 |
// CHECK-NOT: sanitize_memtag |
| 33 |
// CHECK: @{{.*}}disable_instrumentation_global{{.*}} = |
| 34 |
// CHECK-NOT: sanitize_memtag |
| 35 |
// CHECK: @{{.*}}ignorelisted_global{{.*}} = |
| 36 |
// CHECK-NOT: sanitize_memtag |
| 37 |
|
| 38 |
// CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag |
| 39 |
// CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag |
| 40 |
// CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag |
| 41 |
|
| 42 |
// IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag |
| 43 |
|
| 44 |
// IGNORELIST: @{{.*}}global{{.*}} = |
| 45 |
// IGNORELIST-NOT: sanitize_memtag |
| 46 |
// IGNORELIST: @{{.*}}attributed_global{{.*}} = |
| 47 |
// IGNORELIST-NOT: sanitize_memtag |
| 48 |
// IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} = |
| 49 |
// IGNORELIST-NOT: sanitize_memtag |
| 50 |
// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} = |
| 51 |
// IGNORELIST-NOT: sanitize_memtag |
| 52 |
// IGNORELIST: @{{.*}}static_var{{.*}} = |
| 53 |
// IGNORELIST-NOT: sanitize_memtag |
| 54 |
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} |
| 55 |
// IGNORELIST-NOT: sanitize_memtag |
| 56 |
// IGNORELIST: @{{.*}}external_global{{.*}} = |
| 57 |
// IGNORELIST-NOT: sanitize_memtag |