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