1 //===-- Implementation file of __libc_init_array --------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/macros/config.h"
13 namespace LIBC_NAMESPACE_DECL
{
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