Static variable initialisation
Hi,
I'm trying to set up a custom bootloader to run on one of the STM3210x processors. I am experiencing hardfaults during startup and it's while it's trying to initialise a static variable, specifically in the aeabi_atexit -> _cxa_atexit -> _register_exitproc methods which from what I can work out is registering the destructor method for this static variable.
There is a obviously a gap in my knowledge about how this is supposed to work and also what I should be expecting and I have not been able to find much useful information about this online.
I am using gcc-arm-
ENTRY(reset_
MEMORY
{
UNPLACED_SECTIONS : ORIGIN = 0x100000000, LENGTH = 0
SRAM : ORIGIN = 0x20000000, LENGTH = 0x00008000
FLASH : ORIGIN = 0x08000000, LENGTH = 0x00002e00
}
/* Include the HAL definitions - CORTEX-M3 and STM32 registers */
INCLUDE Hal.ld
INCLUDE Extra.ld
__STACKSIZE__ = 3096;
SECTIONS
{
/******
* FLASH SECTION
*******
. = 0x08000000;
__vectors_start__ = .;
.vectors ALIGN(4) : {
KEEP(*(.vectors .vectors.*))
}
__vectors_end__ = __vectors_start__ + SIZEOF(.vectors);
/* .init => Process initialisation code (code that gets run before main) */
.init ALIGN(4) : {
__init_start__ = .;
*(.init .init.*)
}
__init_end__ = __init_start__ + SIZEOF(.init);
/* .fini => Process termination code (when the program exits normally, the system will execute this code) */
.fini ALIGN(4) : {
__fini_start__ = .;
KEEP(*(.fini))
}
__fini_end__ = __fini_start__ + SIZEOF(.fini);
/* .eh_frame => Exception handling code that helps with stack unwinding */
/* TODO = STRIP LATER? */
.eh_frame ALIGN(4) : {
*(.eh_frame)
}
/* .ARM.exidx => Used for exception handing */
/* TODO = STRIP LATER? */
.ARM.exidx ALIGN(4) : {
__exidx_start = .;
*(.ARM.exidx)
*(.ARM.exidx*)
}
__exidx_end = __exidx_start + SIZEOF(.ARM.exidx);
/* .text => Holds the program */
.text ALIGN(4) : {
__text_
__text_start__ = .;
*(.text)
*(.text*)
}
__text_end__ = __text_start__ + SIZEOF(.text);
__etext = __text_end__;
/* .dtors => Contains a list of global destructor pointers */
.dtors ALIGN(4) : {
__dtors_
__dtors_start__ = .;
KEEP(
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
__dtors_end__ = __dtors_start__ + SIZEOF(.dtors);
/* .ctors => Contains a list of global constructor pointers */
.ctors ALIGN(4) : {
__ctors_
__ctors_start__ = .;
KEEP(
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
__ctors_end__ = __ctors_start__ + SIZEOF(.ctors);
/* .rodata => read-only data */
.rodata ALIGN(4) : {
__rodata_
__rodata_
*(.rodata)
*(.rodata*)
}
__rodata_end__ = __rodata_start__ + SIZEOF(.rodata);
/* .jcr => Contains information necessary for registering compiled Java classes */
.jcr ALIGN(4) : {
*(.jcr)
}
/* .glue = ARM glue code */
.linker_stubs ALIGN(4) : {
*(.glue_7*)
*(.rel*)
*(.
*(.v4_bx)
*(.iplt)
*(.igot*)
}
/DISCARD/ : {
*(.
}
/******
* RAM SECTION
*******
. = 0x20000000;
/* We create our vector table in RAM after initialization */
.vectors_ram ALIGN(4) (NOLOAD) : {
__vectors_
KEEP(
. = MAX(__vectors_
}
__vectors_
. = 0x20000144;
.bss ALIGN(4) (NOLOAD) : {
__bss_start__ = .;
*(.bss)
*(.bss*)
}
__bss_end__ = __bss_start__ + SIZEOF(.bss);
/* .data => Initalised data that contributes to the */
.data ALIGN(4) (NOLOAD) : {
__data_
__data_start__ = .;
*(.data .data.* .gnu.linkonce.d.*)
}
__data_end__ = __data_start__ + SIZEOF(.data);
.stack ALIGN(4) (NOLOAD) : {
__stack_start__ = .;
*(.stack)
. = ALIGN(MAX(
}
__stack_end__ = __stack_start__ + SIZEOF(.stack);
.heap ALIGN(4) (NOLOAD) : {
__heap_start__ = .;
*(.heap)
}
__heap_end__ = __heap_start__ + SIZEOF(.heap);
}
Any suggestions into working out what is going on would be greatly appreciated.
Thanks
Paul
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Paul Manners
- Solved:
- Last query:
- Last reply: