| 1 |
// Make sure the sanitize_address attribute is emitted when using ASan, KASan or |
| 2 |
// HWASan. Either __attribute__((no_sanitize("address")) or |
| 3 |
// __attribute__((no_sanitize("kernel-address")) disables both ASan and KASan |
| 4 |
// instrumentation. |
| 5 |
// Same for __attribute__((no_sanitize("hwaddress")) and |
| 6 |
// __attribute__((no_sanitize("kernel-hwddress")) and HWASan and KHWASan. |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -triple i386-unknown-linux -disable-O0-optnone \ |
| 9 |
// RUN: -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=address \ |
| 12 |
// RUN: -disable-O0-optnone -emit-llvm -o - %s | \ |
| 13 |
// RUN: FileCheck -check-prefix=CHECK-ASAN %s |
| 14 |
|
| 15 |
// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-address \ |
| 16 |
// RUN: -disable-O0-optnone -emit-llvm -o - %s | \ |
| 17 |
// RUN: FileCheck -check-prefix=CHECK-KASAN %s |
| 18 |
|
| 19 |
// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=hwaddress \ |
| 20 |
// RUN: -disable-O0-optnone -emit-llvm -o - %s | \ |
| 21 |
// RUN: FileCheck -check-prefix=CHECK-HWASAN %s |
| 22 |
|
| 23 |
// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-hwaddress \ |
| 24 |
// RUN: -disable-O0-optnone -emit-llvm -o - %s | \ |
| 25 |
// RUN: FileCheck -check-prefix=CHECK-KHWASAN %s |
| 26 |
|
| 27 |
int HasSanitizeAddress() { return 1; } |
| 28 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 29 |
// CHECK-ASAN: Function Attrs: mustprogress noinline nounwind sanitize_address |
| 30 |
// CHECK-KASAN: Function Attrs: mustprogress noinline nounwind sanitize_address |
| 31 |
// CHECK-HWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress |
| 32 |
// CHECK-KHWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress |
| 33 |
|
| 34 |
__attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() { |
| 35 |
return 0; |
| 36 |
} |
| 37 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 38 |
// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 39 |
// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 40 |
// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 41 |
// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 42 |
|
| 43 |
__attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; } |
| 44 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 45 |
// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 46 |
// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 47 |
// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 48 |
// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 49 |
|
| 50 |
__attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() { |
| 51 |
return 0; |
| 52 |
} |
| 53 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 54 |
// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 55 |
// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 56 |
// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 57 |
// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}} |
| 58 |
|
| 59 |
__attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() { |
| 60 |
return 0; |
| 61 |
} |
| 62 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 63 |
// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} |
| 64 |
// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} |
| 65 |
// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 66 |
// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 67 |
|
| 68 |
__attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() { |
| 69 |
return 0; |
| 70 |
} |
| 71 |
// CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 72 |
// CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} |
| 73 |
// CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}} |
| 74 |
// CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 75 |
// CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}} |
| 76 |
|
| 77 |
__attribute__((disable_sanitizer_instrumentation)) int DisableSanitizerInstrumentation() { |
| 78 |
return 0; |
| 79 |
} |
| 80 |
// CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} |
| 81 |
// CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} |
| 82 |
// CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} |
| 83 |
// CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} |
| 84 |
// CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}} |