aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-09-13 03:23:03 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-09-13 04:44:02 -0400
commit514cc1c190300af2bdfd94a0ae1a37d416d3c125 (patch)
treeff94c10660658c4f7884d11d73683df2920a7fae /support
parentaf9c6c9f7143067fb48f5bb3eb1474003dcb5017 (diff)
downloadlibrambutan-514cc1c190300af2bdfd94a0ae1a37d416d3c125.tar.gz
librambutan-514cc1c190300af2bdfd94a0ae1a37d416d3c125.zip
[support/ld] Unify linker scripts.
Add new common.inc, which is common_rom.inc with some DEFINED(_FLASH_BUILD) usages thrown in to allow for RAM builds. It also uses a new REGION_RODATA region alias for read-only data. Move section .USER_FLASH to REGION_RODATA. This means it lives in RAM under RAM builds. Although this might be surprising, not doing so would make RAM builds useless. Modify the individual board linker scripts to properly set REGION_RODATA and _FLASH_BUILD before calling out to common.inc. Delete common_rom.inc, common_ram.inc, common_header.inc, in favor of common.inc. This should fix RAM builds on all boards.
Diffstat (limited to 'support')
-rw-r--r--support/ld/common.inc (renamed from support/ld/common_rom.inc)67
-rw-r--r--support/ld/common_header.inc37
-rw-r--r--support/ld/common_ram.inc188
-rw-r--r--support/ld/maple/flash.ld5
-rw-r--r--support/ld/maple/jtag.ld4
-rw-r--r--support/ld/maple/ram.ld3
-rw-r--r--support/ld/maple_RET6/flash.ld4
-rw-r--r--support/ld/maple_RET6/jtag.ld4
-rw-r--r--support/ld/maple_RET6/ram.ld3
-rw-r--r--support/ld/maple_mini/flash.ld4
-rw-r--r--support/ld/maple_mini/jtag.ld4
-rw-r--r--support/ld/maple_mini/ram.ld3
-rw-r--r--support/ld/maple_native/flash.ld4
-rw-r--r--support/ld/maple_native/jtag.ld4
-rw-r--r--support/ld/maple_native/ram.ld3
15 files changed, 89 insertions, 248 deletions
diff --git a/support/ld/common_rom.inc b/support/ld/common.inc
index 7182a4d..b53c4f6 100644
--- a/support/ld/common_rom.inc
+++ b/support/ld/common.inc
@@ -1,17 +1,53 @@
/*
- * Linker script for Flash (ROM) builds.
+ * Linker script for libmaple.
*
* Original author "lanchon" from ST forums, with modifications by LeafLabs.
*/
-INCLUDE common_header.inc
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+ENTRY(_start)
+SEARCH_DIR(.)
+
+/*
+ * Link against libgcc, libc, and libm
+ */
+GROUP(libgcc.a libc.a libm.a)
+
+/* These force the linker to search for particular symbols from
+ * the start of the link process and thus ensure the user's
+ * overrides are picked up
+ */
+INCLUDE names.inc
+
+/* STM32 vector table. See stm32_vector_table.S */
+EXTERN(__cs3_stm32_vector_table)
+
+/* libcs3 C start function. See cs3.h */
+EXTERN(__cs3_start_c)
+
+/* main entry point */
+EXTERN(main)
+
+/* Initial stack pointer value. */
+EXTERN(__cs3_stack)
+PROVIDE(__cs3_stack = __cs3_region_start_ram + LENGTH(ram));
+
+/* Reset vector and chip reset entry point. See start.S */
+EXTERN(_start)
+PROVIDE(__cs3_reset = _start);
+
+/* Heap boundaries, for libmaple */
+EXTERN(_lm_heap_start);
+EXTERN(_lm_heap_end);
SECTIONS
{
+ /* TODO pull out rodata and stick into separate sections */
.text :
{
+ __text_start = .;
/*
- * STM32 vector table
+ * STM32 vector table. Leave this here. Yes, really.
*/
*(.stm32.interrupt_vector)
@@ -23,8 +59,6 @@ SECTIONS
*(.gnu.warning)
*(.glue_7t) *(.glue_7) *(.vfp11_veneer)
- *(.rodata .rodata.* .gnu.linkonce.r.*)
-
*(.ARM.extab* .gnu.linkonce.armextab.*)
*(.gcc_except_table)
*(.eh_frame_hdr)
@@ -77,13 +111,21 @@ SECTIONS
} > REGION_TEXT
/*
+ * Read-only data
+ */
+ .rodata :
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ } > REGION_RODATA
+
+ /*
* .ARM.exidx exception unwinding; mandated by ARM's C++ ABI
*/
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
- } > REGION_TEXT
+ } > REGION_RODATA
__exidx_end = .;
/*
@@ -101,19 +143,18 @@ SECTIONS
.USER_FLASH :
{
*(.USER_FLASH)
- } > rom
+ } > REGION_RODATA
/*
* .data
*/
.data :
{
- __cs3_region_start_ram = .;
+ __cs3_region_start_ram = DEFINED(_FLASH_BUILD) ? . : __text_start;
*(.got.plt) *(.got)
*(.data .data.* .gnu.linkonce.d.*)
-
/*
* Heap: Linker scripts may choose a custom heap by overriding
* _lm_heap_start and _lm_heap_end. Otherwise, the heap is in
@@ -144,8 +185,12 @@ SECTIONS
* Constants needed for the pieces of CS3 we use during
* board startup; see libcs3_stm32_src/.
*/
- __cs3_region_init_ram = LOADADDR (.data);
- __cs3_region_init_size_ram = _edata - ADDR (.data);
+ __cs3_region_init_ram = (DEFINED(_FLASH_BUILD) ?
+ LOADADDR(.data) :
+ LOADADDR(.text));
+ __cs3_region_init_size_ram = (DEFINED(_FLASH_BUILD) ?
+ _edata - ADDR(.data) :
+ _edata - ADDR(.text));
__cs3_region_zero_size_ram = _end - _edata;
__cs3_region_num = 1;
diff --git a/support/ld/common_header.inc b/support/ld/common_header.inc
deleted file mode 100644
index 1d11ba0..0000000
--- a/support/ld/common_header.inc
+++ /dev/null
@@ -1,37 +0,0 @@
-/* "Preamble" for linker scripts (such as common_rom.inc) */
-
-OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
-ENTRY(_start)
-SEARCH_DIR(.)
-
-/*
- * Link against libgcc, libc, and libm
- */
-GROUP(libgcc.a libc.a libm.a)
-
-/* These force the linker to search for particular symbols from
- * the start of the link process and thus ensure the user's
- * overrides are picked up
- */
-INCLUDE names.inc
-
-/* STM32 vector table. See stm32_vector_table.S */
-EXTERN(__cs3_stm32_vector_table)
-
-/* libcs3 C start function. See cs3.h */
-EXTERN(__cs3_start_c)
-
-/* main entry point */
-EXTERN(main)
-
-/* Initial stack pointer value. */
-EXTERN(__cs3_stack)
-PROVIDE(__cs3_stack = __cs3_region_start_ram + LENGTH(ram));
-
-/* Reset vector and chip reset entry point. See start.S */
-EXTERN(_start)
-PROVIDE(__cs3_reset = _start);
-
-/* Heap boundaries, for libmaple */
-EXTERN(_lm_heap_start);
-EXTERN(_lm_heap_end);
diff --git a/support/ld/common_ram.inc b/support/ld/common_ram.inc
deleted file mode 100644
index ea51a9f..0000000
--- a/support/ld/common_ram.inc
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Linker script for RAM builds.
- *
- * Original author "lanchon" from ST forums, with modifications by LeafLabs.
- */
-
-INCLUDE common_header.inc
-
-SECTIONS
-{
- .text :
- {
- CREATE_OBJECT_SYMBOLS
- __cs3_region_start_ram = .;
-
- /*
- * STM32 vector table
- */
- __cs3_interrupt_vector = __cs3_stm32_vector_table;
- *(.cs3.interrupt_vector)
- /* Make sure we pulled in an interrupt vector. */
- ASSERT (. != __cs3_stm32_vector_table, "No interrupt vector");
-
- /*
- * Program code and vague linking
- */
- *(.text .text.* .gnu.linkonce.t.*)
- *(.plt)
- *(.gnu.warning)
- *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
-
- *(.rodata .rodata.* .gnu.linkonce.r.*)
-
- *(.ARM.extab* .gnu.linkonce.armextab.*)
- *(.gcc_except_table)
- *(.eh_frame_hdr)
- *(.eh_frame)
-
- . = ALIGN(4);
- KEEP(*(.init))
-
- . = ALIGN(4);
- __preinit_array_start = .;
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-
- . = ALIGN(4);
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*crtend.o(.ctors))
-
- . = ALIGN(4);
- KEEP(*(.fini))
-
- . = ALIGN(4);
- __fini_array_start = .;
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- __fini_array_end = .;
-
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*crtend.o(.dtors))
-
- . = ALIGN(4);
- __cs3_regions = .;
- LONG (0)
- LONG (__cs3_region_init_ram)
- LONG (__cs3_region_start_ram)
- LONG (__cs3_region_init_size_ram)
- LONG (__cs3_region_zero_size_ram)
- } > REGION_TEXT
-
- /*
- * .ARM.exidx exception unwinding
- */
- __exidx_start = .;
- .ARM.exidx :
- {
- *(.ARM.exidx* .gnu.linkonce.armexidx.*)
- } > REGION_TEXT
- __exidx_end = .;
-
- /*
- * End of text
- */
- .text.align :
- {
- . = ALIGN(8);
- _etext = .;
- } > REGION_TEXT
-
- .cs3.rom :
- {
- __cs3_region_start_rom = .;
- *(.rom)
- . = ALIGN (8);
- } > ram
-
- .cs3.rom.bss :
- {
- *(.rom.b)
- . = ALIGN (8);
- } > ram
-
- /* __cs3_region_end_rom is deprecated */
- __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(ram);
- __cs3_region_size_rom = LENGTH(ram);
- __cs3_region_init_rom = LOADADDR (.cs3.rom);
- __cs3_region_init_size_rom = SIZEOF(.cs3.rom);
- __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);
-
- /*
- * Start of data
- */
- .data :
- {
- KEEP(*(.jcr))
- *(.got.plt) *(.got)
- *(.shdata)
- *(.data .data.* .gnu.linkonce.d.*)
- *(.ram)
- . = ALIGN (8);
- _edata = .;
- } > REGION_DATA
-
- .bss :
- {
- *(.shbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- *(.ram.b)
- . = ALIGN (8);
- _end = .;
- __end = .;
- } > REGION_BSS
-
- /* __cs3_region_end_ram is deprecated */
- __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);
- __cs3_region_size_ram = LENGTH(ram);
- __cs3_region_init_ram = LOADADDR (.text);
- __cs3_region_init_size_ram = _edata - ADDR (.text);
- __cs3_region_zero_size_ram = _end - _edata;
- __cs3_region_num = 1;
-
- /*
- * Debugging sections
- */
- .stab 0 (NOLOAD) : { *(.stab) }
- .stabstr 0 (NOLOAD) : { *(.stabstr) }
- /* DWARF debug sections.
- * Symbols in the DWARF debugging sections are relative to the beginning
- * of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-
- .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
- .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
- /DISCARD/ : { *(.note.GNU-stack) }
-}
diff --git a/support/ld/maple/flash.ld b/support/ld/maple/flash.ld
index e9ff4b4..8a179f7 100644
--- a/support/ld/maple/flash.ld
+++ b/support/ld/maple/flash.ld
@@ -19,8 +19,11 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/*
* Define the rest of the sections
*/
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+
+INCLUDE common.inc
diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld
index ed8cc1c..365068f 100644
--- a/support/ld/maple/jtag.ld
+++ b/support/ld/maple/jtag.ld
@@ -20,8 +20,10 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/*
* Define the rest of the sections
*/
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple/ram.ld b/support/ld/maple/ram.ld
index 09bcb33..6f237c3 100644
--- a/support/ld/maple/ram.ld
+++ b/support/ld/maple/ram.ld
@@ -19,8 +19,9 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", ram);
/*
* Define the rest of the sections
*/
-INCLUDE common_ram.inc
+INCLUDE common.inc
diff --git a/support/ld/maple_RET6/flash.ld b/support/ld/maple_RET6/flash.ld
index 524ed71..4cf9c4b 100644
--- a/support/ld/maple_RET6/flash.ld
+++ b/support/ld/maple_RET6/flash.ld
@@ -14,5 +14,7 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_RET6/jtag.ld b/support/ld/maple_RET6/jtag.ld
index 3a8e41f..6055dfb 100644
--- a/support/ld/maple_RET6/jtag.ld
+++ b/support/ld/maple_RET6/jtag.ld
@@ -14,5 +14,7 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_RET6/ram.ld b/support/ld/maple_RET6/ram.ld
index 787eb31..a4c273b 100644
--- a/support/ld/maple_RET6/ram.ld
+++ b/support/ld/maple_RET6/ram.ld
@@ -14,5 +14,6 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", ram);
-INCLUDE common_ram.inc
+INCLUDE common.inc
diff --git a/support/ld/maple_mini/flash.ld b/support/ld/maple_mini/flash.ld
index 37d765e..ab03207 100644
--- a/support/ld/maple_mini/flash.ld
+++ b/support/ld/maple_mini/flash.ld
@@ -19,8 +19,10 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/*
* Define the rest of the sections
*/
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_mini/jtag.ld b/support/ld/maple_mini/jtag.ld
index a26e1b6..2f9cf31 100644
--- a/support/ld/maple_mini/jtag.ld
+++ b/support/ld/maple_mini/jtag.ld
@@ -20,8 +20,10 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/*
* Define the rest of the sections
*/
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_mini/ram.ld b/support/ld/maple_mini/ram.ld
index 3bf33c9..0ba0252 100644
--- a/support/ld/maple_mini/ram.ld
+++ b/support/ld/maple_mini/ram.ld
@@ -19,8 +19,9 @@ GROUP(libcs3_stm32_med_density.a)
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", ram);
/*
* Define the rest of the sections
*/
-INCLUDE common_ram.inc
+INCLUDE common.inc
diff --git a/support/ld/maple_native/flash.ld b/support/ld/maple_native/flash.ld
index 20326e4..b6e10f8 100644
--- a/support/ld/maple_native/flash.ld
+++ b/support/ld/maple_native/flash.ld
@@ -16,10 +16,12 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/* Specify heap boundary addresses on the external SRAM chip */
_lm_heap_start = 0x60000000;
_lm_heap_end = 0x60100000;
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_native/jtag.ld b/support/ld/maple_native/jtag.ld
index 73157de..9af2a11 100644
--- a/support/ld/maple_native/jtag.ld
+++ b/support/ld/maple_native/jtag.ld
@@ -17,9 +17,11 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", rom);
/* Specify heap boundary addresses on the external SRAM chip */
_lm_heap_start = 0x60000000;
_lm_heap_end = 0x60100000;
-INCLUDE common_rom.inc
+_FLASH_BUILD = 1;
+INCLUDE common.inc
diff --git a/support/ld/maple_native/ram.ld b/support/ld/maple_native/ram.ld
index d38e43c..7264316 100644
--- a/support/ld/maple_native/ram.ld
+++ b/support/ld/maple_native/ram.ld
@@ -16,9 +16,10 @@ GROUP(libcs3_stm32_high_density.a)
REGION_ALIAS("REGION_TEXT", ram);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_BSS", ram);
+REGION_ALIAS("REGION_RODATA", ram);
/* Specify heap boundary addresses on the external SRAM chip */
_lm_heap_start = 0x60000000;
_lm_heap_end = 0x60100000;
-INCLUDE common_ram.inc
+INCLUDE common.inc