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