aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support/ld/common.inc53
-rw-r--r--wirish/start_c.c19
2 files changed, 33 insertions, 39 deletions
diff --git a/support/ld/common.inc b/support/ld/common.inc
index 926f9eb..f749b19 100644
--- a/support/ld/common.inc
+++ b/support/ld/common.inc
@@ -102,29 +102,6 @@ SECTIONS
} > REGION_TEXT
/*
- * Read-only data
- */
- .rodata :
- {
- *(.rodata .rodata.* .gnu.linkonce.r.*)
-
- /* ROM image configuration; for C startup */
- . = ALIGN(4);
- _lm_rom_img_cfgp = .;
- LONG(LOADADDR(.data));
- } > REGION_RODATA
-
- /*
- * .ARM.exidx exception unwinding; mandated by ARM's C++ ABI
- */
- __exidx_start = .;
- .ARM.exidx :
- {
- *(.ARM.exidx* .gnu.linkonce.armexidx.*)
- } > REGION_RODATA
- __exidx_end = .;
-
- /*
* End of text
*/
.text.align :
@@ -134,12 +111,14 @@ SECTIONS
} > REGION_TEXT
/*
- * .USER_FLASH: We allow users to allocate into Flash here
+ * .ARM.exidx exception unwinding; mandated by ARM's C++ ABI
*/
- .USER_FLASH :
+ __exidx_start = .;
+ .ARM.exidx :
{
- *(.USER_FLASH)
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > REGION_RODATA
+ __exidx_end = .;
/*
* .data
@@ -152,6 +131,22 @@ SECTIONS
*(.got.plt) *(.got)
*(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN(8);
+ _edata = .;
+ } > REGION_DATA AT> REGION_RODATA
+
+ /*
+ * Read-only data
+ */
+ .rodata :
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ /* .USER_FLASH: We allow users to allocate into Flash here */
+ *(.USER_FLASH)
+ /* ROM image configuration; for C startup */
+ . = ALIGN(4);
+ _lm_rom_img_cfgp = .;
+ LONG(LOADADDR(.data));
/*
* Heap: Linker scripts may choose a custom heap by overriding
* _lm_heap_start and _lm_heap_end. Otherwise, the heap is in
@@ -163,9 +158,7 @@ SECTIONS
*/
_lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : _end;
_lm_heap_end = DEFINED(_lm_heap_end) ? _lm_heap_end : __msp_init;
- . = ALIGN (8);
- _edata = .;
- } > REGION_DATA AT> REGION_TEXT
+ } > REGION_RODATA
/*
* .bss
@@ -179,7 +172,7 @@ SECTIONS
. = ALIGN (8);
_ebss = .;
_end = _ebss;
- } > REGION_BSS AT> REGION_TEXT
+ } > REGION_BSS
/*
* Debugging sections
diff --git a/wirish/start_c.c b/wirish/start_c.c
index ae42087..301565c 100644
--- a/wirish/start_c.c
+++ b/wirish/start_c.c
@@ -54,39 +54,40 @@ extern char _data, _edata;
extern char _bss, _ebss;
struct rom_img_cfg {
- long long *img_start;
+ int *img_start;
};
extern char _lm_rom_img_cfgp;
void __attribute__((noreturn)) start_c(void) {
struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp;
- long long *src;
- long long *dst;
+ int *src = img_cfg->img_start;
+ int *dst = (int*)&_data;
int exit_code;
/* Initialize .data, if necessary. */
- src = img_cfg->img_start;
- dst = (long long*)&_data;
if (src != dst) {
- while (dst < (long long*)&_edata) {
+ int *end = (int*)&_edata;
+ while (dst < end) {
*dst++ = *src++;
}
}
/* Zero .bss. */
- dst = (long long*)&_bss;
- while (dst < (long long*)&_ebss) {
+ dst = (int*)&_bss;
+ while (dst < (int*)&_ebss) {
*dst++ = 0;
}
/* Run initializers. */
__libc_init_array();
- exit_code = main(0, NULL, NULL);
+ /* Jump to main. */
+ exit_code = main(0, 0, 0);
if (exit) {
exit(exit_code);
}
+
/* If exit is NULL, make sure we don't return. */
for (;;)
continue;