Files
clang-p2996/compiler-rt/test/dfsan/flush.c
George Balatsouras 5b4dda550e [dfsan] Add full fast8 support
Complete support for fast8:
- amend shadow size and mapping in runtime
- remove fast16 mode and -dfsan-fast-16-labels flag
- remove legacy mode and make fast8 mode the default
- remove dfsan-fast-8-labels flag
- remove functions in dfsan interface only applicable to legacy
- remove legacy-related instrumentation code and tests
- update documentation.

Reviewed By: stephan.yichao.zhao, browneee

Differential Revision: https://reviews.llvm.org/D103745
2021-06-07 17:20:54 -07:00

41 lines
1022 B
C

// Tests dfsan_flush().
// RUN: %clang_dfsan %s -o %t && %run %t
// RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
//
// REQUIRES: x86_64-target-arch
#include <sanitizer/dfsan_interface.h>
#include <assert.h>
#include <stdlib.h>
int global;
int main() {
int local;
int *heap = (int*)malloc(sizeof(int));
dfsan_set_label(10, &global, sizeof(global));
dfsan_set_label(20, &local, sizeof(local));
dfsan_set_label(30, heap, sizeof(*heap));
assert(dfsan_get_label(global) == 10);
assert(dfsan_get_label(local) == 20);
assert(dfsan_get_label(*heap) == 30);
#ifdef ORIGIN_TRACKING
assert(dfsan_get_origin(global));
assert(dfsan_get_origin(local));
assert(dfsan_get_origin(*heap));
#endif
dfsan_flush();
assert(dfsan_get_label(global) == 0);
assert(dfsan_get_label(local) == 0);
assert(dfsan_get_label(*heap) == 0);
assert(dfsan_get_origin(global) == 0);
assert(dfsan_get_origin(local) == 0);
assert(dfsan_get_origin(*heap) == 0);
free(heap);
}