From c375b5ac7ae8dc0d9a309f2d8559db1719c14f7f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 28 Feb 2021 19:09:49 +0000 Subject: [PATCH] Added .iwram section (#118) * Added .iwram section * Use the same section for .data and .text_iwram --- linker.ld | 13 +++++++++++-- src/rsrt0.S | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/linker.ld b/linker.ld index 47bdfab..9f013f5 100644 --- a/linker.ld +++ b/linker.ld @@ -18,12 +18,21 @@ SECTIONS { . = ALIGN(4); } >rom = 0xff - __data_lma = .; - .data : { + __iwram_lma = .; + .iwram : { + __iwram_start = ABSOLUTE(.); + __data_start = ABSOLUTE(.); *(.data .data.*); . = ALIGN(4); __data_end = ABSOLUTE(.); + + __text_iwram_start = ABSOLUTE(.); + *(.text_iwram .text_iwram.*); + . = ALIGN(4); + __text_iwram_end = ABSOLUTE(.); + + __iwram_end = ABSOLUTE(.); } >iwram AT>rom = 0xff .bss : { diff --git a/src/rsrt0.S b/src/rsrt0.S index b45e64f..7e0e137 100644 --- a/src/rsrt0.S +++ b/src/rsrt0.S @@ -21,13 +21,13 @@ __start: msr CPSR_c, r0 ldr sp, =0x3007f00 - @ copy .data section to IWRAM - ldr r0, =__data_lma @ source address - ldr r1, =__data_start @ destination address - ldr r2, =__data_end + @ copy .data and .text_iwram section to IWRAM + ldr r0, =__iwram_lma @ source address + ldr r1, =__iwram_start @ destination address + ldr r2, =__iwram_end subs r2, r1 @ length @ these instructions are only executed if r2 is nonzero - @ (i.e. don't bother copying an empty .data section) + @ (i.e. don't bother copying an empty .iwram section) addne r2, #3 asrne r2, #2 addne r2, #0x04000000