gcc __attribute__((constructor)): Remove hacked calling, move ctor sections to flash
More hacky moving of parts of .rodata to flash, until we can move all of it. Candidate fix for #128
This commit is contained in:
parent
2badeed523
commit
b61b62136b
4 changed files with 33 additions and 46 deletions
|
@ -178,9 +178,6 @@ void xPortSysTickHandle (void)
|
||||||
//OpenNMI();
|
//OpenNMI();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sdk_compat_initialised;
|
|
||||||
void sdk_compat_initialise(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See header file for description.
|
* See header file for description.
|
||||||
*/
|
*/
|
||||||
|
@ -189,14 +186,6 @@ portBASE_TYPE xPortStartScheduler( void )
|
||||||
_xt_isr_attach(INUM_SOFT, SV_ISR);
|
_xt_isr_attach(INUM_SOFT, SV_ISR);
|
||||||
_xt_isr_unmask(BIT(INUM_SOFT));
|
_xt_isr_unmask(BIT(INUM_SOFT));
|
||||||
|
|
||||||
/* ENORMOUS HACK: Call the sdk_compat_initialise() function.
|
|
||||||
This can be removed happily once we have open source startup code.
|
|
||||||
*/
|
|
||||||
if(!sdk_compat_initialised) {
|
|
||||||
sdk_compat_initialised = true;
|
|
||||||
sdk_compat_initialise();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize system tick timer interrupt and schedule the first tick. */
|
/* Initialize system tick timer interrupt and schedule the first tick. */
|
||||||
_xt_isr_attach(INUM_TICK, sdk__xt_timer_int);
|
_xt_isr_attach(INUM_TICK, sdk__xt_timer_int);
|
||||||
_xt_isr_unmask(BIT(INUM_TICK));
|
_xt_isr_unmask(BIT(INUM_TICK));
|
||||||
|
|
|
@ -407,6 +407,9 @@ void sdk_user_init_task(void *params) {
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void (*__init_array_start)(void);
|
||||||
|
extern void (*__init_array_end)(void);
|
||||||
|
|
||||||
// .Lfunc009 -- .irom0.text+0x5b4
|
// .Lfunc009 -- .irom0.text+0x5b4
|
||||||
static void user_start_phase2(void) {
|
static void user_start_phase2(void) {
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
@ -437,6 +440,12 @@ static void user_start_phase2(void) {
|
||||||
uart_flush_txfifo(0);
|
uart_flush_txfifo(0);
|
||||||
uart_flush_txfifo(1);
|
uart_flush_txfifo(1);
|
||||||
|
|
||||||
|
// Call gcc constructor functions
|
||||||
|
void (**ctor)(void);
|
||||||
|
for ( ctor = &__init_array_start; ctor != &__init_array_end; ++ctor) {
|
||||||
|
(*ctor)();
|
||||||
|
}
|
||||||
|
|
||||||
if (phy_info[0] != 5) {
|
if (phy_info[0] != 5) {
|
||||||
// Bad version byte. Discard what we read and use default values
|
// Bad version byte. Discard what we read and use default values
|
||||||
// instead.
|
// instead.
|
||||||
|
|
|
@ -17,20 +17,6 @@ void IRAM *zalloc(size_t nbytes)
|
||||||
return calloc(1, nbytes);
|
return calloc(1, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void (*__init_array_start)(void);
|
|
||||||
extern void (*__init_array_end)(void);
|
|
||||||
|
|
||||||
/* Do things which should be done as part of the SDK startup code, but aren't.
|
|
||||||
TODO: Move into app_main.c
|
|
||||||
*/
|
|
||||||
void sdk_compat_initialise()
|
|
||||||
{
|
|
||||||
/* Call C++ constructors or C functions marked with __attribute__((constructor)) */
|
|
||||||
void (**p)(void);
|
|
||||||
for ( p = &__init_array_start; p != &__init_array_end; ++p)
|
|
||||||
(*p)();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* UART RX function from Espressif SDK internals.
|
/* UART RX function from Espressif SDK internals.
|
||||||
*
|
*
|
||||||
* Not part of published API.
|
* Not part of published API.
|
||||||
|
|
45
ld/common.ld
45
ld/common.ld
|
@ -139,13 +139,34 @@ SECTIONS
|
||||||
(except for libgcc which is matched above.)
|
(except for libgcc which is matched above.)
|
||||||
*/
|
*/
|
||||||
*(.literal .text .literal.* .text.*)
|
*(.literal .text .literal.* .text.*)
|
||||||
|
/* Anything explicitly marked as "irom" or "irom0" should go here */
|
||||||
|
*(.irom.* .irom.*.* .irom0.*)
|
||||||
|
_irom0_text_end = ABSOLUTE(.);
|
||||||
|
|
||||||
|
/* Temporary .rodata hacks start here, eventually all rodata will
|
||||||
|
be in irom by default */
|
||||||
/* mbedtls rodata */
|
/* mbedtls rodata */
|
||||||
*mbedtls.a:*.o(.rodata.* .rodata)
|
*mbedtls.a:*.o(.rodata.* .rodata)
|
||||||
/* actual certificate in example (TEMPORARY HACK) */
|
/* actual certificate in example (TEMPORARY HACK) */
|
||||||
*:cert.o(.rodata.* .rodata)
|
*:cert.o(.rodata.* .rodata)
|
||||||
/* Anything explicitly marked as "irom" or "irom0" should go here */
|
/* C++ constructor and destructor tables, properly ordered: */
|
||||||
*(.irom.* .irom.*.* .irom0.*)
|
__init_array_start = ABSOLUTE(.);
|
||||||
_irom0_text_end = ABSOLUTE(.);
|
KEEP (*crtbegin.o(.ctors))
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||||
|
KEEP (*(SORT(.ctors.*)))
|
||||||
|
KEEP (*(.ctors))
|
||||||
|
__init_array_end = ABSOLUTE(.);
|
||||||
|
KEEP (*crtbegin.o(.dtors))
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||||
|
KEEP (*(SORT(.dtors.*)))
|
||||||
|
KEEP (*(.dtors))
|
||||||
|
/* C++ exception handlers table: */
|
||||||
|
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
|
||||||
|
*(.xt_except_desc)
|
||||||
|
*(.gnu.linkonce.h.*)
|
||||||
|
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
||||||
|
*(.xt_except_desc_end)
|
||||||
|
|
||||||
} >irom0_0_seg :irom0_0_phdr
|
} >irom0_0_seg :irom0_0_phdr
|
||||||
|
|
||||||
.data : ALIGN(4)
|
.data : ALIGN(4)
|
||||||
|
@ -179,23 +200,6 @@ SECTIONS
|
||||||
*(.gnu.version_r)
|
*(.gnu.version_r)
|
||||||
*(.eh_frame)
|
*(.eh_frame)
|
||||||
. = (. + 3) & ~ 3;
|
. = (. + 3) & ~ 3;
|
||||||
/* C++ constructor and destructor tables, properly ordered: */
|
|
||||||
__init_array_start = ABSOLUTE(.);
|
|
||||||
KEEP (*crtbegin.o(.ctors))
|
|
||||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
|
||||||
KEEP (*(SORT(.ctors.*)))
|
|
||||||
KEEP (*(.ctors))
|
|
||||||
__init_array_end = ABSOLUTE(.);
|
|
||||||
KEEP (*crtbegin.o(.dtors))
|
|
||||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
|
||||||
KEEP (*(SORT(.dtors.*)))
|
|
||||||
KEEP (*(.dtors))
|
|
||||||
/* C++ exception handlers table: */
|
|
||||||
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
|
|
||||||
*(.xt_except_desc)
|
|
||||||
*(.gnu.linkonce.h.*)
|
|
||||||
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
|
||||||
*(.xt_except_desc_end)
|
|
||||||
*(.dynamic)
|
*(.dynamic)
|
||||||
*(.gnu.version_d)
|
*(.gnu.version_d)
|
||||||
. = ALIGN(4); /* this table MUST be 4-byte aligned */
|
. = ALIGN(4); /* this table MUST be 4-byte aligned */
|
||||||
|
@ -230,7 +234,6 @@ SECTIONS
|
||||||
} >dram0_0_seg :dram0_0_bss_phdr
|
} >dram0_0_seg :dram0_0_bss_phdr
|
||||||
/* __stack = 0x3ffc8000; */
|
/* __stack = 0x3ffc8000; */
|
||||||
|
|
||||||
|
|
||||||
.lit4 : ALIGN(4)
|
.lit4 : ALIGN(4)
|
||||||
{
|
{
|
||||||
_lit4_start = ABSOLUTE(.);
|
_lit4_start = ABSOLUTE(.);
|
||||||
|
|
Loading…
Reference in a new issue