1 // RUN: %clangxx_hwasan -DSIZE=16 -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
3 // REQUIRES: stable-runtime
8 #include <sanitizer/hwasan_interface.h>
11 char *alloc
= (char *)malloc(4096);
13 // Simulate short granule tags.
21 // __hwasan_tag_memory expects untagged pointers.
22 char *p
= (char *)__hwasan_tag_pointer(alloc
, 0);
25 // Write tags to shadow.
26 __hwasan_tag_memory(p
, 1, 32);
27 __hwasan_tag_memory(p
+ 32, 16, 16);
28 __hwasan_tag_memory(p
+ 48, 0, 32);
29 __hwasan_tag_memory(p
+ 80, 4, 16);
31 char *q
= (char *)__hwasan_tag_pointer(p
, 7);
32 __hwasan_print_shadow(q
+ 5, 89 - 5);
33 // CHECK: HWASan shadow map for {{.*}}5 .. {{.*}}9 (pointer tag 7)
34 // CHECK-NEXT: {{.*}}0: 01(00)
35 // CHECK-NEXT: {{.*}}0: 01(bb)
36 // CHECK-NEXT: {{.*}}0: 10
37 // CHECK-NEXT: {{.*}}0: 00
38 // CHECK-NEXT: {{.*}}0: 00
39 // CHECK-NEXT: {{.*}}0: 04(ff)