[LLD][COFF] Emit tail merge pdata for delay load thunks on ARM64EC (#116810)
[llvm-project.git] / libc / startup / baremetal / init.cpp
blobce387017c4972fbef5e409144edcc47d570f033a
1 //===-- Implementation file of __libc_init_array --------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/macros/config.h"
10 #include <stddef.h>
11 #include <stdint.h>
13 namespace LIBC_NAMESPACE_DECL {
15 extern "C" {
16 extern uintptr_t __preinit_array_start[];
17 extern uintptr_t __preinit_array_end[];
18 extern uintptr_t __init_array_start[];
19 extern uintptr_t __init_array_end[];
22 using InitCallback = void(void);
24 extern "C" void __libc_init_array(void) {
25 size_t preinit_array_size = __preinit_array_end - __preinit_array_start;
26 for (size_t i = 0; i < preinit_array_size; ++i)
27 reinterpret_cast<InitCallback *>(__preinit_array_start[i])();
28 size_t init_array_size = __init_array_end - __init_array_start;
29 for (size_t i = 0; i < init_array_size; ++i)
30 reinterpret_cast<InitCallback *>(__init_array_start[i])();
33 } // namespace LIBC_NAMESPACE_DECL