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_set_label(label: 8, addr: &a, size: sizeof(a)); |
17 | uint64_t c = foo(a, b); |
18 | dfsan_print_origin_trace(addr: &c, NULL); |
19 | dfsan_print_origin_trace(addr: (int*)(&c) + 1, NULL); |
20 | } |
21 | |
22 | // CHECK: Taint value 0x8 {{.*}} origin tracking () |
23 | // CHECK: Origin value: {{.*}}, Taint value was stored to memory at |
24 | // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-7]] |
25 | |
26 | // CHECK: Origin value: {{.*}}, Taint value was created at |
27 | // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-11]] |
28 | |
29 | // CHECK: Taint value 0x8 {{.*}} origin tracking () |
30 | // CHECK: Origin value: {{.*}}, Taint value was stored to memory at |
31 | // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-14]] |
32 | |
33 | // CHECK: Origin value: {{.*}}, Taint value was created at |
34 | // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-18]] |
35 | |