CPP: fix static objects init for MWDT toolchain
The constructors of static objects are stored in ".ctors" section. In case of MWDT toolchain we have incompatible ".ctors" section format with GNU toolchain. So let's use initialization code provided by MWDT instead of Zephyr one in case of MWDT toolchain usage. As it is done for GNU toolchain We call constructors of static objects but we don't call destructors for them. Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
This commit is contained in:
parent
3682eb9714
commit
497cb2e587
7 changed files with 69 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources(
|
||||
zephyr_sources(cpp_init.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_CPP_STATIC_INIT_GNU
|
||||
cpp_init_array.c
|
||||
cpp_ctors.c
|
||||
cpp_dtors.c
|
||||
|
|
|
@ -75,4 +75,12 @@ config RTTI
|
|||
|
||||
endif # LIB_CPLUSPLUS
|
||||
|
||||
config CPP_STATIC_INIT_GNU
|
||||
# As of today only ARC MWDT toolchain doesn't support GNU-compatible
|
||||
# initialization of CPP static objects, new toolchains can be added
|
||||
# here if required.
|
||||
def_bool "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "arcmwdt"
|
||||
help
|
||||
GNU-compatible initialization of CPP static objects
|
||||
|
||||
endif # CPLUSPLUS
|
||||
|
|
31
subsys/cpp/cpp_init.c
Normal file
31
subsys/cpp/cpp_init.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Synopsys, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Author: Evgeniy Paltsev
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CPP_STATIC_INIT_GNU
|
||||
|
||||
void __do_global_ctors_aux(void);
|
||||
void __do_init_array_aux(void);
|
||||
|
||||
void z_cpp_init_static(void)
|
||||
{
|
||||
__do_global_ctors_aux();
|
||||
__do_init_array_aux();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __CCAC__
|
||||
void _init(void);
|
||||
|
||||
void z_cpp_init_static(void)
|
||||
{
|
||||
_init();
|
||||
}
|
||||
#endif /* __CCAC__ */
|
||||
|
||||
#endif /* CONFIG_CPP_STATIC_INIT_GNU */
|
Loading…
Add table
Add a link
Reference in a new issue