linker: ensure global constructors only run once
Rename the symbols used to denote the locations of the global constructor lists and modify the Zephyr start-up code accordingly. On POSIX systems this ensures that the native libc init code won't find any constructors to run before Zephyr loads. Fixes #39347, #36858 Signed-off-by: David Palchak <palchak@google.com>
This commit is contained in:
parent
be606f0932
commit
b4a7f0f2ca
4 changed files with 39 additions and 14 deletions
|
@ -21,8 +21,8 @@ typedef void (*CtorFuncPtr)(void);
|
|||
|
||||
/* Constructor function pointer list is generated by the linker script. */
|
||||
|
||||
extern CtorFuncPtr __CTOR_LIST__[];
|
||||
extern CtorFuncPtr __CTOR_END__[];
|
||||
extern CtorFuncPtr __ZEPHYR_CTOR_LIST__[];
|
||||
extern CtorFuncPtr __ZEPHYR_CTOR_END__[];
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -35,9 +35,9 @@ void __do_global_ctors_aux(void)
|
|||
{
|
||||
unsigned int nCtors;
|
||||
|
||||
nCtors = (unsigned long)__CTOR_LIST__[0];
|
||||
nCtors = (unsigned long)__ZEPHYR_CTOR_LIST__[0];
|
||||
|
||||
while (nCtors >= 1U) {
|
||||
__CTOR_LIST__[nCtors--]();
|
||||
__ZEPHYR_CTOR_LIST__[nCtors--]();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue