• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
HasSanitizeAddress()27 int HasSanitizeAddress() { return 1; }
28 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
29 // CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address mustprogress
30 // CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address mustprogress
31 // CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress mustprogress
32 // CHECK-KHWASAN: Function Attrs: noinline nounwind sanitize_hwaddress mustprogress
33 
NoSanitizeQuoteAddress()34 __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() {
35   return 0;
36 }
37 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
38 // CHECK-ASAN: {{Function Attrs: noinline nounwind mustprogress$}}
39 // CHECK-KASAN: {{Function Attrs: noinline nounwind mustprogress$}}
40 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
41 // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
42 
NoSanitizeAddress()43 __attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; }
44 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
45 // CHECK-ASAN: {{Function Attrs: noinline nounwind mustprogress$}}
46 // CHECK-KASAN: {{Function Attrs: noinline nounwind mustprogress$}}
47 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
48 // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
49 
NoSanitizeKernelAddress()50 __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() {
51   return 0;
52 }
53 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
54 // CHECK-ASAN: {{Function Attrs: noinline nounwind mustprogress$}}
55 // CHECK-KASAN: {{Function Attrs: noinline nounwind mustprogress$}}
56 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
57 // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress mustprogress$}}
58 
NoSanitizeHWAddress()59 __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() {
60   return 0;
61 }
62 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
63 // CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address mustprogress$}}
64 // CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address mustprogress$}}
65 // CHECK-HWASAN: {{Function Attrs: noinline nounwind mustprogress$}}
66 // CHECK-KHWASAN: {{Function Attrs: noinline nounwind mustprogress$}}
67 
NoSanitizeKernelHWAddress()68 __attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() {
69   return 0;
70 }
71 // CHECK-NOASAN: {{Function Attrs: noinline nounwind mustprogress$}}
72 // CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address mustprogress$}}
73 // CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address mustprogress$}}
74 // CHECK-HWASAN: {{Function Attrs: noinline nounwind mustprogress$}}
75 // CHECK-KHWASAN: {{Function Attrs: noinline nounwind mustprogress$}}
76