1 //===-- esan_interface_internal.h -------------------------------*- 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 // This file is a part of EfficiencySanitizer, a family of performance tuners. 11 // 12 // Calls to the functions declared in this header will be inserted by 13 // the instrumentation module. 14 //===----------------------------------------------------------------------===// 15 16 #ifndef ESAN_INTERFACE_INTERNAL_H 17 #define ESAN_INTERFACE_INTERNAL_H 18 19 #include <sanitizer_common/sanitizer_internal_defs.h> 20 21 // This header should NOT include any other headers. 22 // All functions in this header are extern "C" and start with __esan_. 23 24 extern "C" { 25 26 // This should be kept consistent with LLVM's EfficiencySanitizerOptions. 27 // The value is passed as a 32-bit integer by the compiler. 28 typedef enum Type : u32 { 29 ESAN_None = 0, 30 ESAN_CacheFrag, 31 ESAN_WorkingSet, 32 ESAN_Max, 33 } ToolType; 34 35 // To handle interceptors that invoke instrumented code prior to 36 // __esan_init() being called, the instrumentation module creates this 37 // global variable specifying the tool. 38 extern ToolType __esan_which_tool; 39 40 // This function should be called at the very beginning of the process, 41 // before any instrumented code is executed and before any call to malloc. 42 SANITIZER_INTERFACE_ATTRIBUTE void __esan_init(ToolType Tool, void *Ptr); 43 SANITIZER_INTERFACE_ATTRIBUTE void __esan_exit(void *Ptr); 44 45 // The instrumentation module will insert a call to one of these routines prior 46 // to each load and store instruction for which we do not have "fastpath" 47 // inlined instrumentation. These calls constitute the "slowpath" for our 48 // tools. We have separate routines for each type of memory access to enable 49 // targeted optimization. 50 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load1(void *Addr); 51 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load2(void *Addr); 52 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load4(void *Addr); 53 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load8(void *Addr); 54 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_load16(void *Addr); 55 56 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store1(void *Addr); 57 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store2(void *Addr); 58 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store4(void *Addr); 59 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store8(void *Addr); 60 SANITIZER_INTERFACE_ATTRIBUTE void __esan_aligned_store16(void *Addr); 61 62 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load2(void *Addr); 63 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load4(void *Addr); 64 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load8(void *Addr); 65 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_load16(void *Addr); 66 67 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store2(void *Addr); 68 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store4(void *Addr); 69 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store8(void *Addr); 70 SANITIZER_INTERFACE_ATTRIBUTE void __esan_unaligned_store16(void *Addr); 71 72 // These cover unusually-sized accesses. 73 SANITIZER_INTERFACE_ATTRIBUTE 74 void __esan_unaligned_loadN(void *Addr, uptr Size); 75 SANITIZER_INTERFACE_ATTRIBUTE 76 void __esan_unaligned_storeN(void *Addr, uptr Size); 77 78 } // extern "C" 79 80 #endif // ESAN_INTERFACE_INTERNAL_H 81