forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib c/cpp: Move .ctor .init_array handling from C++ to kernel
* Move ctors and init_array from the CPP library to the kernel library, as this is common for both C and C++ and it is the kernel who is running it. * Rename the hidden kconfig option CPP_STATIC_INIT_GNU STATIC_INIT_GNU instead. * If STATIC_INIT_GNU is not selected verify there is constructors left behind. * Rename common-rom-cpp.ld to common-rom-init.ld * Rename z_cpp_init_static to z_init_static, and have the kernel always call it. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no> Signed-off-by: Keith Packard <keithp@keithp.com>
- Loading branch information
Showing
22 changed files
with
149 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ list(APPEND kernel_files | |
errno.c | ||
fatal.c | ||
init.c | ||
init_static.c | ||
kheap.c | ||
mem_slab.c | ||
float.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2012-2015 Wind River Systems, Inc. | ||
* Copyright (c) 2021 Synopsys, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
void __do_global_ctors_aux(void); | ||
void __do_init_array_aux(void); | ||
|
||
void z_init_static(void) | ||
{ | ||
#if defined(CONFIG_STATIC_INIT_GNU) | ||
__do_global_ctors_aux(); | ||
__do_init_array_aux(); | ||
#elif defined(__CCAC__) /* ARC MWDT */ | ||
__do_global_ctors_aux(); | ||
#endif | ||
} | ||
|
||
/** | ||
* @section - Constructor module | ||
* @brief | ||
* The ctors section contains a list of function pointers that execute both the C++ constructors of | ||
* static global objects, as well as either C or C++ initializer functions (declared with the | ||
* attribute constructor). These must be executed before the application's main() routine. | ||
* | ||
* NOTE: Not all compilers put those function pointers into the ctors section; | ||
* some put them into the init_array section instead. | ||
*/ | ||
|
||
#ifdef CONFIG_STATIC_INIT_GNU | ||
|
||
/* What a constructor function pointer looks like */ | ||
|
||
typedef void (*CtorFuncPtr)(void); | ||
|
||
/* Constructor function pointer list is generated by the linker script. */ | ||
|
||
extern CtorFuncPtr __ZEPHYR_CTOR_LIST__[]; | ||
extern CtorFuncPtr __ZEPHYR_CTOR_END__[]; | ||
|
||
/** | ||
* | ||
* @brief Invoke all C++ style global object constructors | ||
* | ||
* This routine is invoked by the kernel prior to the execution of the | ||
* application's main(). | ||
*/ | ||
void __do_global_ctors_aux(void) | ||
{ | ||
unsigned int nCtors; | ||
|
||
nCtors = (unsigned long)__ZEPHYR_CTOR_LIST__[0]; | ||
|
||
while (nCtors >= 1U) { | ||
__ZEPHYR_CTOR_LIST__[nCtors--](); | ||
} | ||
} | ||
|
||
#endif | ||
|
||
/* | ||
* @section | ||
* @brief Execute initialization routines referenced in .init_array section | ||
*/ | ||
|
||
#ifdef CONFIG_STATIC_INIT_GNU | ||
|
||
typedef void (*func_ptr)(void); | ||
|
||
extern func_ptr __zephyr_init_array_start[]; | ||
extern func_ptr __zephyr_init_array_end[]; | ||
|
||
/** | ||
* @brief Execute initialization routines referenced in .init_array section | ||
*/ | ||
void __do_init_array_aux(void) | ||
{ | ||
for (func_ptr *func = __zephyr_init_array_start; | ||
func < __zephyr_init_array_end; | ||
func++) { | ||
(*func)(); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_sources(cpp_init.c) | ||
|
||
zephyr_sources_ifdef(CONFIG_CPP_STATIC_INIT_GNU | ||
cpp_init_array.c | ||
cpp_ctors.c | ||
zephyr_sources_ifdef(CONFIG_STATIC_INIT_GNU | ||
cpp_dtors.c | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.