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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
//===-- esan_interface.cpp ------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of EfficiencySanitizer, a family of performance tuners.
//
//===----------------------------------------------------------------------===//
#include "esan_interface_internal.h"
#include "esan.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
using namespace __esan; // NOLINT
void __esan_init(ToolType Tool, void *Ptr) {
if (Tool != __esan_which_tool) {
Printf("ERROR: tool mismatch: %d vs %d\n", Tool, __esan_which_tool);
Die();
}
initializeLibrary(Tool);
processCompilationUnitInit(Ptr);
}
void __esan_exit(void *Ptr) {
processCompilationUnitExit(Ptr);
}
void __esan_aligned_load1(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, false);
}
void __esan_aligned_load2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
}
void __esan_aligned_load4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
}
void __esan_aligned_load8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
}
void __esan_aligned_load16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
}
void __esan_aligned_store1(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 1, true);
}
void __esan_aligned_store2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
}
void __esan_aligned_store4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
}
void __esan_aligned_store8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
}
void __esan_aligned_store16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
}
void __esan_unaligned_load2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, false);
}
void __esan_unaligned_load4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, false);
}
void __esan_unaligned_load8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, false);
}
void __esan_unaligned_load16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, false);
}
void __esan_unaligned_store2(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 2, true);
}
void __esan_unaligned_store4(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 4, true);
}
void __esan_unaligned_store8(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 8, true);
}
void __esan_unaligned_store16(void *Addr) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, 16, true);
}
void __esan_unaligned_loadN(void *Addr, uptr Size) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, false);
}
void __esan_unaligned_storeN(void *Addr, uptr Size) {
processRangeAccess(GET_CALLER_PC(), (uptr)Addr, Size, true);
}
// Public interface:
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE void __esan_report() {
reportResults();
}
SANITIZER_INTERFACE_ATTRIBUTE unsigned int __esan_get_sample_count() {
return getSampleCount();
}
} // extern "C"
|