diff options
Diffstat (limited to 'libsanitizer/lsan/lsan_preinit.cc')
-rw-r--r-- | libsanitizer/lsan/lsan_preinit.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libsanitizer/lsan/lsan_preinit.cc b/libsanitizer/lsan/lsan_preinit.cc new file mode 100644 index 00000000000..856f9f78787 --- /dev/null +++ b/libsanitizer/lsan/lsan_preinit.cc @@ -0,0 +1,24 @@ +//===-- lsan_preinit.cc ---------------------------------------------------===// +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of LeakSanitizer. +// +// Call __lsan_init at the very early stage of process startup. +//===----------------------------------------------------------------------===// + +#include "lsan.h" + +#ifndef LSAN_USE_PREINIT_ARRAY +#define LSAN_USE_PREINIT_ARRAY 1 +#endif + +#if LSAN_USE_PREINIT_ARRAY && !defined(PIC) + // We force __lsan_init to be called before anyone else by placing it into + // .preinit_array section. + __attribute__((section(".preinit_array"), used)) + void (*__local_lsan_preinit)(void) = __lsan_init; +#endif |