I have a Cortex-M3 project compiled with GCC. The startup_LPC177x_8x.s code copies the initialized data from flash to RAM, initializes the bss, calls the clock initialization SystemInit
. Before calling the _main
function the code also calls the function _libc_init_array
.
The __libc_init_array function calls all initialization routines that are defined in the __preinit_array
, calls the _init
function, and all routines that are defined in the __init_array
:
void __libc_init_array (void)
{
size_t count;
size_t i;
count = __preinit_array_end - __preinit_array_start;
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
_init ();
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
__init_array_start[i] ();
}
With GDB I could find that the __preinit_array
is empty (start==end), and that the second call to __init_array_start[i] ()
crashes.
I have no idea what functions are included in this array. The linker script causes all .init.array.*
section to be located here. But how do I find the corresponding .o
and source files?
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
Maybe I can help you here -
run
and you will recieve a list of adresses, like
now, if you have compiled this thing yourself, you can now run
to get filename and line number of the functions in question.
Does that help?