1 // RUN: %clang_dfsan -gmlt -DOFFSET=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
2 // RUN: %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
5 // RUN: %clang_dfsan -gmlt -DOFFSET=10 -mllvm -dfsan-track-origins=1 %s -o %t && \
6 // RUN: %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
9 // REQUIRES: x86_64-target-arch
11 #include <sanitizer/dfsan_interface.h>
17 volatile int idx
= 30;
19 __attribute__((noinline
)) void fn_g(char a
, char b
) {
20 xx
[idx
] = a
; xx
[idx
+ 10] = b
;
23 __attribute__((noinline
)) void fn_f(char a
, char b
) {
27 __attribute__((noinline
)) void fn_h() {
28 memcpy(&yy
[2], &xx
[2], sizeof(xx
) - 4);
31 __attribute__((noinline
)) void fn_i() {
32 memmove(&yy
[25], &yy
, 7500);
35 int main(int argc
, char *argv
[]) {
37 int volatile buffer
= 0;
39 dfsan_set_label(8, (void *)&z1
, sizeof(z1
));
40 dfsan_set_label(16, (void *)&z2
, sizeof(z2
));
44 dfsan_print_origin_trace(&yy
[25 + idx
+ OFFSET
], NULL
);
48 // CHECK0: Taint value 0x8 {{.*}} origin tracking ()
49 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
50 // CHECK0: #0 {{.*}} in fn_i.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-18]]
51 // CHECK0: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-8]]
53 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
54 // CHECK0: #0 {{.*}} in fn_h.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-26]]
55 // CHECK0: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-13]]
57 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
58 // CHECK0: #0 {{.*}} in fn_g.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-38]]
59 // CHECK0: #1 {{.*}} in fn_f.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-35]]
60 // CHECK0: #2 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-19]]
62 // CHECK0: Origin value: {{.*}}, Taint value was created at
63 // CHECK0: #0 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-24]]
65 // CHECK10: Taint value 0x10 {{.*}} origin tracking
66 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
67 // CHECK10: #0 {{.*}} in fn_i.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-35]]
68 // CHECK10: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-25]]
70 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
71 // CHECK10: #0 {{.*}} in fn_h.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-43]]
72 // CHECK10: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-30]]
74 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
75 // CHECK10: #0 {{.*}} in fn_g.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-55]]
76 // CHECK10: #1 {{.*}} in fn_f.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-52]]
77 // CHECK10: #2 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-36]]
79 // CHECK10: Origin value: {{.*}}, Taint value was created at
80 // CHECK10: #0 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-40]]