1//===-- scudo_interceptors.cpp ----------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9/// 10/// Linux specific malloc interception functions. 11/// 12//===----------------------------------------------------------------------===// 13 14#include "sanitizer_common/sanitizer_platform.h" 15#if SANITIZER_LINUX 16 17#include "scudo_allocator.h" 18 19#include "interception/interception.h" 20 21using namespace __scudo; 22 23INTERCEPTOR(void, free, void *ptr) { 24 scudoFree(ptr, FromMalloc); 25} 26 27INTERCEPTOR(void, cfree, void *ptr) { 28 scudoFree(ptr, FromMalloc); 29} 30 31INTERCEPTOR(void*, malloc, uptr size) { 32 return scudoMalloc(size, FromMalloc); 33} 34 35INTERCEPTOR(void*, realloc, void *ptr, uptr size) { 36 return scudoRealloc(ptr, size); 37} 38 39INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) { 40 return scudoCalloc(nmemb, size); 41} 42 43INTERCEPTOR(void*, valloc, uptr size) { 44 return scudoValloc(size); 45} 46 47INTERCEPTOR(void*, memalign, uptr alignment, uptr size) { 48 return scudoMemalign(alignment, size); 49} 50 51INTERCEPTOR(void*, __libc_memalign, uptr alignment, uptr size) { 52 return scudoMemalign(alignment, size); 53} 54 55INTERCEPTOR(void*, pvalloc, uptr size) { 56 return scudoPvalloc(size); 57} 58 59INTERCEPTOR(void*, aligned_alloc, uptr alignment, uptr size) { 60 return scudoAlignedAlloc(alignment, size); 61} 62 63INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) { 64 return scudoPosixMemalign(memptr, alignment, size); 65} 66 67INTERCEPTOR(uptr, malloc_usable_size, void *ptr) { 68 return scudoMallocUsableSize(ptr); 69} 70 71INTERCEPTOR(int, mallopt, int cmd, int value) { 72 return -1; 73} 74 75#endif // SANITIZER_LINUX 76