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.
Revert "lib c/cpp: Move .ctor .init_array handling from C++ to kernel"
Unfortunately this breaks native_sim fuzzing due (presumably) to interactions with the .ctors emitted by the libc/sanitizer layer. See SOF discussion at thesofproject/sof#9278 This reverts commit 6e977ae. Signed-off-by: Andy Ross <andyross@google.com>
- Loading branch information
Showing
22 changed files
with
131 additions
and
149 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,7 +55,6 @@ 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_sources_ifdef(CONFIG_STATIC_INIT_GNU | ||
zephyr_sources(cpp_init.c) | ||
|
||
zephyr_sources_ifdef(CONFIG_CPP_STATIC_INIT_GNU | ||
cpp_init_array.c | ||
cpp_ctors.c | ||
cpp_dtors.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2012-2014 Wind River Systems, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @file - Constructor module | ||
* @brief | ||
* The ctors section contains a list of function pointers that execute the | ||
* C++ constructors of static global objects. 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. | ||
*/ | ||
|
||
/* 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--](); | ||
} | ||
} |
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,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 __do_global_ctors_aux(void); | ||
|
||
void z_cpp_init_static(void) | ||
{ | ||
__do_global_ctors_aux(); | ||
} | ||
#endif /* __CCAC__ */ | ||
|
||
#endif /* CONFIG_CPP_STATIC_INIT_GNU */ |
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,27 @@ | ||
/* | ||
* Copyright (c) 2015 Wind River Systems, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* | ||
* @file | ||
* @brief Execute initialization routines referenced in .init_array section | ||
*/ | ||
|
||
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)(); | ||
} | ||
} |
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.