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 #include <sanitizer/dfsan_interface.h>
15 volatile int idx
= 30;
17 __attribute__((noinline
)) void fn_g(char a
, char b
) {
18 xx
[idx
] = a
; xx
[idx
+ 10] = b
;
21 __attribute__((noinline
)) void fn_f(char a
, char b
) {
25 __attribute__((noinline
)) void fn_h() {
26 memcpy(&yy
[2], &xx
[2], sizeof(xx
) - 4);
29 __attribute__((noinline
)) void fn_i() {
30 memmove(&yy
[25], &yy
, 7500);
33 int main(int argc
, char *argv
[]) {
35 int volatile buffer
= 0;
37 dfsan_set_label(8, (void *)&z1
, sizeof(z1
));
38 dfsan_set_label(16, (void *)&z2
, sizeof(z2
));
42 dfsan_print_origin_trace(&yy
[25 + idx
+ OFFSET
], NULL
);
46 // CHECK0: Taint value 0x8 {{.*}} origin tracking ()
47 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
48 // CHECK0: #0 {{.*}} in fn_i.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-18]]
49 // CHECK0: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-8]]
51 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
52 // CHECK0: #0 {{.*}} in fn_h.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-26]]
53 // CHECK0: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-13]]
55 // CHECK0: Origin value: {{.*}}, Taint value was stored to memory at
56 // CHECK0: #0 {{.*}} in fn_g.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-38]]
57 // CHECK0: #1 {{.*}} in fn_f.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-35]]
58 // CHECK0: #2 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-19]]
60 // CHECK0: Origin value: {{.*}}, Taint value was created at
61 // CHECK0: #0 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-24]]
63 // CHECK10: Taint value 0x10 {{.*}} origin tracking
64 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
65 // CHECK10: #0 {{.*}} in fn_i.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-35]]
66 // CHECK10: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-25]]
68 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
69 // CHECK10: #0 {{.*}} in fn_h.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-43]]
70 // CHECK10: #1 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-30]]
72 // CHECK10: Origin value: {{.*}}, Taint value was stored to memory at
73 // CHECK10: #0 {{.*}} in fn_g.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-55]]
74 // CHECK10: #1 {{.*}} in fn_f.dfsan {{.*}}origin_unaligned_memtrans.c:[[@LINE-52]]
75 // CHECK10: #2 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-36]]
77 // CHECK10: Origin value: {{.*}}, Taint value was created at
78 // CHECK10: #0 {{.*}} in main {{.*}}origin_unaligned_memtrans.c:[[@LINE-40]]