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