xref: /openbsd-src/gnu/llvm/compiler-rt/lib/memprof/memprof_preinit.cpp (revision d89ec533011f513df1010f142a111086a0785f09)
1*d89ec533Spatrick //===-- memprof_preinit.cpp ----------------------------------------------===//
2*d89ec533Spatrick //
3*d89ec533Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*d89ec533Spatrick // See https://llvm.org/LICENSE.txt for license information.
5*d89ec533Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*d89ec533Spatrick //
7*d89ec533Spatrick //===----------------------------------------------------------------------===//
8*d89ec533Spatrick //
9*d89ec533Spatrick // This file is a part of MemProfiler, a memory profiler.
10*d89ec533Spatrick //
11*d89ec533Spatrick // Call __memprof_init at the very early stage of process startup.
12*d89ec533Spatrick //===----------------------------------------------------------------------===//
13*d89ec533Spatrick #include "memprof_internal.h"
14*d89ec533Spatrick 
15*d89ec533Spatrick using namespace __memprof;
16*d89ec533Spatrick 
17*d89ec533Spatrick #if SANITIZER_CAN_USE_PREINIT_ARRAY
18*d89ec533Spatrick // The symbol is called __local_memprof_preinit, because it's not intended to
19*d89ec533Spatrick // be exported. This code linked into the main executable when -fmemory-profile
20*d89ec533Spatrick // is in the link flags. It can only use exported interface functions.
21*d89ec533Spatrick __attribute__((section(".preinit_array"),
22*d89ec533Spatrick                used)) void (*__local_memprof_preinit)(void) = __memprof_preinit;
23*d89ec533Spatrick #endif
24