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