1353944Sdim//===-- lsan_preinit.cpp --------------------------------------------------===//
2353944Sdim//
3353944Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353944Sdim// See https://llvm.org/LICENSE.txt for license information.
5353944Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6353944Sdim//
7353944Sdim//===----------------------------------------------------------------------===//
8353944Sdim//
9353944Sdim// This file is a part of LeakSanitizer.
10353944Sdim//
11353944Sdim// Call __lsan_init at the very early stage of process startup.
12353944Sdim//===----------------------------------------------------------------------===//
13353944Sdim
14353944Sdim#include "lsan.h"
15353944Sdim
16353944Sdim#if SANITIZER_CAN_USE_PREINIT_ARRAY
17353944Sdim  // We force __lsan_init to be called before anyone else by placing it into
18353944Sdim  // .preinit_array section.
19353944Sdim  __attribute__((section(".preinit_array"), used))
20353944Sdim  void (*__local_lsan_preinit)(void) = __lsan_init;
21353944Sdim#endif
22