Added .iwram section (#118)

* Added .iwram section

* Use the same section for .data and .text_iwram
This commit is contained in:
Joshua Barretto 2021-02-28 19:09:49 +00:00 committed by GitHub
parent 40ced658f3
commit c375b5ac7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View file

@ -18,12 +18,21 @@ SECTIONS {
. = ALIGN(4); . = ALIGN(4);
} >rom = 0xff } >rom = 0xff
__data_lma = .; __iwram_lma = .;
.data : { .iwram : {
__iwram_start = ABSOLUTE(.);
__data_start = ABSOLUTE(.); __data_start = ABSOLUTE(.);
*(.data .data.*); *(.data .data.*);
. = ALIGN(4); . = ALIGN(4);
__data_end = ABSOLUTE(.); __data_end = ABSOLUTE(.);
__text_iwram_start = ABSOLUTE(.);
*(.text_iwram .text_iwram.*);
. = ALIGN(4);
__text_iwram_end = ABSOLUTE(.);
__iwram_end = ABSOLUTE(.);
} >iwram AT>rom = 0xff } >iwram AT>rom = 0xff
.bss : { .bss : {

View file

@ -21,13 +21,13 @@ __start:
msr CPSR_c, r0 msr CPSR_c, r0
ldr sp, =0x3007f00 ldr sp, =0x3007f00
@ copy .data section to IWRAM @ copy .data and .text_iwram section to IWRAM
ldr r0, =__data_lma @ source address ldr r0, =__iwram_lma @ source address
ldr r1, =__data_start @ destination address ldr r1, =__iwram_start @ destination address
ldr r2, =__data_end ldr r2, =__iwram_end
subs r2, r1 @ length subs r2, r1 @ length
@ these instructions are only executed if r2 is nonzero @ 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 addne r2, #3
asrne r2, #2 asrne r2, #2
addne r2, #0x04000000 addne r2, #0x04000000