xref: /freebsd/contrib/llvm-project/compiler-rt/lib/memprof/memprof_preinit.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1e8d8bef9SDimitry Andric //===-- memprof_preinit.cpp ----------------------------------------------===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric //
9e8d8bef9SDimitry Andric // This file is a part of MemProfiler, a memory profiler.
10e8d8bef9SDimitry Andric //
11e8d8bef9SDimitry Andric // Call __memprof_init at the very early stage of process startup.
12e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
13e8d8bef9SDimitry Andric #include "memprof_internal.h"
14e8d8bef9SDimitry Andric 
15e8d8bef9SDimitry Andric using namespace __memprof;
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric #if SANITIZER_CAN_USE_PREINIT_ARRAY
18*0fca6ea1SDimitry Andric // This section is linked into the main executable when -fmemory-profile is
19*0fca6ea1SDimitry Andric // specified to perform initialization at a very early stage.
20*0fca6ea1SDimitry Andric __attribute__((section(".preinit_array"), used)) static auto preinit =
21*0fca6ea1SDimitry Andric     __memprof_preinit;
22e8d8bef9SDimitry Andric #endif
23