Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Init_array not called. #34 #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ld/W806/gcc_csky.ld
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ SECTIONS
*(.rodata*)
*(.rodata.*)
*(.rodata.str1.4)
__ctor_start__ = .;
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__ctor_end__ = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
Expand Down
21 changes: 21 additions & 0 deletions platform/arch/xt804/bsp/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@
#include <csi_config.h>
#include "csi_core.h"

/**
* @brief initialize the system
* Initialize the psr and vbr.
* @param None
* @return None
*/
extern int __dtor_end__;
extern int __ctor_end__;
extern int __ctor_start__;
typedef void (*func_ptr)(void);
__attribute__((weak)) void cxx_system_init(void)
{
func_ptr *p;
for (p = (func_ptr *)&__ctor_end__ -1; p >= (func_ptr *)&__ctor_start__; p--)
{
(*p)();
}
}

/**
* @brief initialize the system
* Initialize the psr and vbr.
Expand Down Expand Up @@ -51,4 +70,6 @@ void SystemInit(void)
#ifdef CONFIG_KERNEL_NONE
__enable_excp_irq();
#endif

cxx_system_init();
}