1 //===-- dfsan_interceptors.cc ---------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of DataFlowSanitizer.
12 // Interceptors for standard library functions.
13 //===----------------------------------------------------------------------===//
15 #include "dfsan/dfsan.h"
16 #include "interception/interception.h"
17 #include "sanitizer_common/sanitizer_common.h"
19 using namespace __sanitizer;
21 INTERCEPTOR(void *, mmap, void *addr, SIZE_T length, int prot, int flags,
22 int fd, OFF_T offset) {
23 void *res = REAL(mmap)(addr, length, prot, flags, fd, offset);
25 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
29 INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
30 int fd, OFF64_T offset) {
31 void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
33 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
38 void InitializeInterceptors() {
39 static int inited = 0;
42 INTERCEPT_FUNCTION(mmap);
43 INTERCEPT_FUNCTION(mmap64);
46 } // namespace __dfsan