summaryrefslogtreecommitdiff
path: root/include/sanitizer
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-06-16 20:06:06 +0000
committerKostya Serebryany <kcc@google.com>2016-06-16 20:06:06 +0000
commit5bb1631a69eb8b8f3c7eca7476e320372c967454 (patch)
treef3df59dc858ce59bb2219a6f4eb5414d594569dd /include/sanitizer
parented4063874ac289bc42a04347853716bb8b74f9de (diff)
[sanitizers] introduce yet another API function: __sanitizer_install_malloc_and_free_hooks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/sanitizer')
-rw-r--r--include/sanitizer/allocator_interface.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/sanitizer/allocator_interface.h b/include/sanitizer/allocator_interface.h
index ab251f89c..522063161 100644
--- a/include/sanitizer/allocator_interface.h
+++ b/include/sanitizer/allocator_interface.h
@@ -59,6 +59,23 @@ extern "C" {
deallocation of "ptr". */
void __sanitizer_malloc_hook(const volatile void *ptr, size_t size);
void __sanitizer_free_hook(const volatile void *ptr);
+
+ /* Installs a pair of hooks for malloc/free.
+ Several (currently, 5) hook pairs may be installed, they are executed
+ in the order they were installed and after calling
+ __sanitizer_malloc_hook/__sanitizer_free_hook.
+ Unlike __sanitizer_malloc_hook/__sanitizer_free_hook these hooks can be
+ chained and do not rely on weak symbols working on the platform, but
+ require __sanitizer_install_malloc_and_free_hooks to be called at startup
+ and thus will not be called on malloc/free very early in the process.
+ Returns the number of hooks currently installed or 0 on failure.
+ Not thread-safe, should be called in the main thread before starting
+ other threads.
+ */
+ int __sanitizer_install_malloc_and_free_hooks(
+ void (*malloc_hook)(const volatile void *, size_t),
+ void (*free_hook)(const volatile void *));
+
#ifdef __cplusplus
} // extern "C"
#endif