1 | // RUN: %clang_dfsan %s -o %t && %run %t |
2 | |
3 | // Tests that labels are propagated through loads and stores. |
4 | |
5 | #include <sanitizer/dfsan_interface.h> |
6 | #include <assert.h> |
7 | |
8 | int main(void) { |
9 | int i = 1; |
10 | dfsan_label i_label = 1; |
11 | dfsan_set_label(label: i_label, addr: &i, size: sizeof(i)); |
12 | |
13 | dfsan_label new_label = dfsan_get_label(data: i); |
14 | assert(i_label == new_label); |
15 | |
16 | dfsan_label read_label = dfsan_read_label(addr: &i, size: sizeof(i)); |
17 | assert(i_label == read_label); |
18 | |
19 | dfsan_label j_label = 2; |
20 | dfsan_add_label(label: j_label, addr: &i, size: sizeof(i)); |
21 | |
22 | read_label = dfsan_read_label(addr: &i, size: sizeof(i)); |
23 | assert(dfsan_has_label(read_label, i_label)); |
24 | assert(dfsan_has_label(read_label, j_label)); |
25 | |
26 | return 0; |
27 | } |
28 | |