jcmvbkbc wrote:Ok, there may be straighter ways of doing that, but the easiest that I've found is that: add the following code to your user_main:Code: Select allextern void (**__init_array_start)(void);
extern void (**__init_array_end)(void);
static void do_global_ctors(void)
{
void (**p)(void);
for (p = __init_array_start; p != __init_array_end; ++p)
(*p)();
}
This does not seem to work. I think you have to take addresses of symbols defined in the linker script instead of using their values. The following works for me:
extern void (*__init_array_start)(void);
extern void (*__init_array_end)(void);
static void do_global_ctors(void)
{
void (**p)(void);
for (p = &__init_array_start; p != &__init_array_end; ++p)
(*p)();
}