1 | // RUN: %clang_dfsan %s -o %t |
2 | // RUN: %run %t |
3 | // |
4 | #include <sanitizer/dfsan_interface.h> |
5 | |
6 | #include <assert.h> |
7 | #include <stdio.h> |
8 | #include <string.h> |
9 | |
10 | int foo(int a, int b) { |
11 | return a + b; |
12 | } |
13 | |
14 | int main(int argc, char *argv[]) { |
15 | int a = 10; |
16 | int b = 20; |
17 | dfsan_set_label(label: 8, addr: &a, size: sizeof(a)); |
18 | dfsan_set_label(label: 128, addr: &b, size: sizeof(b)); |
19 | int c = foo(a, b); |
20 | printf(format: "A: 0x%x\n" , dfsan_get_label(data: a)); |
21 | printf(format: "B: 0x%x\n" , dfsan_get_label(data: b)); |
22 | dfsan_label l = dfsan_get_label(data: c); |
23 | printf(format: "C: 0x%x\n" , l); |
24 | assert(l == 136); // OR of the other two labels. |
25 | } |
26 | |