1 | // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \ |
2 | // RUN: %run %t >%t.out 2>&1 |
3 | // RUN: FileCheck %s < %t.out |
4 | // |
5 | // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 -mllvm -dfsan-instrument-with-call-threshold=0 %s -o %t && \ |
6 | // RUN: %run %t >%t.out 2>&1 |
7 | // RUN: FileCheck %s < %t.out |
8 | |
9 | #include <sanitizer/dfsan_interface.h> |
10 | |
11 | __attribute__((noinline)) uint64_t foo(uint64_t a, uint64_t b) { return a + b; } |
12 | |
13 | int main(int argc, char *argv[]) { |
14 | uint64_t a = 10; |
15 | uint64_t b = 20; |
16 | dfsan_add_label(label: 4, addr: &a, size: sizeof(a)); |
17 | dfsan_add_label(label: 8, addr: &a, size: sizeof(a)); |
18 | uint64_t c = foo(a, b); |
19 | dfsan_print_origin_trace(addr: &c, NULL); |
20 | dfsan_print_origin_trace(addr: (int*)&c + 1, NULL); |
21 | } |
22 | |
23 | // CHECK: Taint value 0xc {{.*}} origin tracking () |
24 | // CHECK: Origin value: {{.*}}, Taint value was stored to memory at |
25 | // CHECK: #0 {{.*}} in main {{.*}}origin_add_label.c:[[@LINE-7]] |
26 | |
27 | // CHECK: Origin value: {{.*}}, Taint value was created at |
28 | // CHECK: #0 {{.*}} in main {{.*}}origin_add_label.c:[[@LINE-11]] |
29 | |
30 | // CHECK: Taint value 0xc {{.*}} origin tracking () |
31 | // CHECK: Origin value: {{.*}}, Taint value was stored to memory at |
32 | // CHECK: #0 {{.*}} in main {{.*}}origin_add_label.c:[[@LINE-14]] |
33 | |
34 | // CHECK: Origin value: {{.*}}, Taint value was created at |
35 | // CHECK: #0 {{.*}} in main {{.*}}origin_add_label.c:[[@LINE-18]] |
36 | |