summaryrefslogtreecommitdiff
path: root/lib/scudo/scudo_interceptors.cpp
blob: 735a1319675755e06ecec3729bc40d0880fbe0d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//===-- scudo_interceptors.cpp ----------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// Linux specific malloc interception functions.
///
//===----------------------------------------------------------------------===//

#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_LINUX

#include "scudo_allocator.h"

#include "interception/interception.h"

using namespace __scudo;

INTERCEPTOR(void, free, void *ptr) {
  scudoFree(ptr, FromMalloc);
}

INTERCEPTOR(void, cfree, void *ptr) {
  scudoFree(ptr, FromMalloc);
}

INTERCEPTOR(void*, malloc, uptr size) {
  return scudoMalloc(size, FromMalloc);
}

INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
  return scudoRealloc(ptr, size);
}

INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
  return scudoCalloc(nmemb, size);
}

INTERCEPTOR(void*, valloc, uptr size) {
  return scudoValloc(size);
}

INTERCEPTOR(void*, memalign, uptr alignment, uptr size) {
  return scudoMemalign(alignment, size);
}

INTERCEPTOR(void*, __libc_memalign, uptr alignment, uptr size) {
  return scudoMemalign(alignment, size);
}

INTERCEPTOR(void*, pvalloc, uptr size) {
  return scudoPvalloc(size);
}

INTERCEPTOR(void*, aligned_alloc, uptr alignment, uptr size) {
  return scudoAlignedAlloc(alignment, size);
}

INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) {
  return scudoPosixMemalign(memptr, alignment, size);
}

INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
  return scudoMallocUsableSize(ptr);
}

INTERCEPTOR(int, mallopt, int cmd, int value) {
  return -1;
}

#endif  // SANITIZER_LINUX