1 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
2 // RUN: %run %t 2>&1 | FileCheck %s
5 #include <sanitizer/dfsan_interface.h>
8 __attribute__((noinline
)) uint64_t foo(uint64_t a
, uint64_t b
) { return a
+ b
; }
10 int main(int argc
, char *argv
[]) {
13 dfsan_set_label(8, &a
, sizeof(a
));
14 uint64_t c
= foo(a
, b
);
16 dfsan_origin c_orig
= dfsan_get_origin(c
);
17 fprintf(stderr
, "c_orig 0x%x\n", c_orig
);
18 // CHECK: c_orig 0x[[#%x,C_ORIG:]]
20 dfsan_print_origin_id_trace(c_orig
);
21 // CHECK: Origin value: 0x[[#%x,C_ORIG]], Taint value was created at
23 uint64_t d
[4] = {1, 2, 3, c
};
24 dfsan_origin d_orig
= dfsan_read_origin_of_first_taint(d
, sizeof(d
));
25 fprintf(stderr
, "d_orig 0x%x\n", d_orig
);
26 // CHECK: d_orig 0x[[#%x,D_ORIG:]]
28 dfsan_print_origin_id_trace(d_orig
);
29 // CHECK: Origin value: 0x[[#%x,D_ORIG]], Taint value was stored to memory at
30 // CHECK: Origin value: 0x[[#%x,C_ORIG]], Taint value was created at