summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2018-08-30 12:50:04 +0200
committerStefan Agner <stefan.agner@toradex.com>2018-08-30 12:50:04 +0200
commite8fdfaef2028dc68c3cb48f5be5c0ab6327fd1bd (patch)
treee36489cea41ad06037fbda40c9125b618ab071c1
parent1a503cf169b7c46e2f749d85fd0310b8e38fb355 (diff)
store .data section directly in RAM area
Since the use of a elf binary is anyway required, we can place sections freely in memory. Therefor it is not necessary to store the variable initialization section (.data) after the code (.text) section and copy it in the firmwares startup code. Instead, just let the elf loader load the .data section directly to its final place. With that the program header look like this: Program Header: LOAD off 0x00001000 vaddr 0x00000000 paddr 0x00000000 align 2**12 filesz 0x00000240 memsz 0x00000240 flags r-- LOAD off 0x00002000 vaddr 0x1fff8000 paddr 0x1fff8000 align 2**12 filesz 0x00006534 memsz 0x00006534 flags rwx LOAD off 0x00009000 vaddr 0x20000000 paddr 0x20000000 align 2**12 filesz 0x000001d0 memsz 0x00005dc8 flags rw- Note the additional program header which loads the .data section directly to the data region at 0x20000000. This safes space in the code region and slightly improves the startup time since the copy loop is not required. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4.ld12
-rw-r--r--platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S31
2 files changed, 1 insertions, 42 deletions
diff --git a/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4.ld b/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4.ld
index 2feebd8..6699153 100644
--- a/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4.ld
+++ b/platform/devices/MCIMX7D/linker/gcc/MCIMX7D_M4.ld
@@ -142,25 +142,15 @@ SECTIONS
PROVIDE_HIDDEN (__fini_array_end = .);
} > m_text
- __etext = .; /* define a global symbol at end of code */
- __DATA_ROM = .; /* Symbol is used by startup for data initialization */
-
- .data : AT(__DATA_ROM)
+ .data :
{
. = ALIGN(4);
- __DATA_RAM = .;
- __data_start__ = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
KEEP(*(.jcr*))
. = ALIGN(4);
- __data_end__ = .; /* define a global symbol at data end */
} > m_data
- __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
- text_end = ORIGIN(m_text) + LENGTH(m_text);
- ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
-
/* Uninitialized data section */
.bss :
{
diff --git a/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S b/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S
index 2a97408..a518a15 100644
--- a/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S
+++ b/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S
@@ -219,37 +219,6 @@ Reset_Handler:
#ifndef __NO_SYSTEM_INIT
bl SystemInit
#endif
-/* Loop to copy data from read only memory to RAM. The ranges
- * of copy from/to are specified by following symbols evaluated in
- * linker script.
- * __etext: End of code section, i.e., begin of data sections to copy from.
- * __data_start__/__data_end__: RAM address range that data should be
- * copied to. Both must be aligned to 4 bytes boundary. */
-
- ldr r1, =__etext
- ldr r2, =__data_start__
- ldr r3, =__data_end__
-
-#if 1
-/* Here are two copies of loop implemenations. First one favors code size
- * and the second one favors performance. Default uses the first one.
- * Change to "#if 0" to use the second one */
-.LC0:
- cmp r2, r3
- ittt lt
- ldrlt r0, [r1], #4
- strlt r0, [r2], #4
- blt .LC0
-#else
- subs r3, r2
- ble .LC1
-.LC0:
- subs r3, #4
- ldr r0, [r1, r3]
- str r0, [r2, r3]
- bgt .LC0
-.LC1:
-#endif
#ifdef __STARTUP_CLEAR_BSS
/* This part of work usually is done in C library startup code. Otherwise,