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 INTERCEPTOR(void *, mmap, void *addr, SIZE_T length, int prot, int flags,
20 int fd, OFF_T offset) {
21 void *res = REAL(mmap)(addr, length, prot, flags, fd, offset);
23 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
27 INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
28 int fd, OFF64_T offset) {
29 void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
31 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
36 void InitializeInterceptors() {
37 static int inited = 0;
40 INTERCEPT_FUNCTION(mmap);
41 INTERCEPT_FUNCTION(mmap64);
44 } // namespace __dfsan