From f7434a4bf3dc953c7db235235f1e4d272af64aa8 Mon Sep 17 00:00:00 2001 From: Corwin Date: Tue, 17 Oct 2023 20:29:12 +0100 Subject: [PATCH] run linker script update script --- book/games/pong/gba.ld | 30 ++++++++------------- examples/amplitude/gba.ld | 30 ++++++++------------- examples/combo/gba.ld | 30 ++++++++------------- examples/hyperspace-roll/gba.ld | 30 ++++++++------------- examples/the-dungeon-puzzlers-lament/gba.ld | 30 ++++++++------------- examples/the-hat-chooses-the-wizard/gba.ld | 30 ++++++++------------- examples/the-purple-night/gba.ld | 30 ++++++++------------- template/gba.ld | 30 ++++++++------------- tracker/agb-tracker/gba.ld | 30 ++++++++------------- 9 files changed, 99 insertions(+), 171 deletions(-) diff --git a/book/games/pong/gba.ld b/book/games/pong/gba.ld index 525260d9..47917308 100644 --- a/book/games/pong/gba.ld +++ b/book/games/pong/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/amplitude/gba.ld b/examples/amplitude/gba.ld index 525260d9..47917308 100644 --- a/examples/amplitude/gba.ld +++ b/examples/amplitude/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/combo/gba.ld b/examples/combo/gba.ld index 525260d9..47917308 100644 --- a/examples/combo/gba.ld +++ b/examples/combo/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/hyperspace-roll/gba.ld b/examples/hyperspace-roll/gba.ld index 525260d9..47917308 100644 --- a/examples/hyperspace-roll/gba.ld +++ b/examples/hyperspace-roll/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/the-dungeon-puzzlers-lament/gba.ld b/examples/the-dungeon-puzzlers-lament/gba.ld index 525260d9..47917308 100644 --- a/examples/the-dungeon-puzzlers-lament/gba.ld +++ b/examples/the-dungeon-puzzlers-lament/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/the-hat-chooses-the-wizard/gba.ld b/examples/the-hat-chooses-the-wizard/gba.ld index 525260d9..47917308 100644 --- a/examples/the-hat-chooses-the-wizard/gba.ld +++ b/examples/the-hat-chooses-the-wizard/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/examples/the-purple-night/gba.ld b/examples/the-purple-night/gba.ld index 525260d9..47917308 100644 --- a/examples/the-purple-night/gba.ld +++ b/examples/the-purple-night/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/template/gba.ld b/template/gba.ld index 525260d9..47917308 100644 --- a/template/gba.ld +++ b/template/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) } diff --git a/tracker/agb-tracker/gba.ld b/tracker/agb-tracker/gba.ld index 525260d9..47917308 100644 --- a/tracker/agb-tracker/gba.ld +++ b/tracker/agb-tracker/gba.ld @@ -7,9 +7,13 @@ EXTERN(__RUST_INTERRUPT_HANDLER) EXTERN(__agbabi_memset) EXTERN(__agbabi_memcpy) +/* The bios reserves the final 256 bytes of iwram for its exclusive use, so we + * need to avoid writing there */ +__bios_reserved_iwram = 256; + MEMORY { ewram (w!x) : ORIGIN = 0x02000000, LENGTH = 256K - iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K + iwram (w!x) : ORIGIN = 0x03000000, LENGTH = 32K - __bios_reserved_iwram rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M } @@ -32,33 +36,27 @@ SECTIONS { . = ALIGN(4); } > rom - __iwram_rom_start = .; .iwram : { - __iwram_data_start = ABSOLUTE(.); - *(.iwram .iwram.*); . = ALIGN(4); *(.text_iwram .text_iwram.*); . = ALIGN(4); - - __iwram_data_end = ABSOLUTE(.); } > iwram AT>rom + __iwram_data_start = ADDR(.iwram); + __iwram_rom_start = LOADADDR(.iwram); + __iwram_rom_length_halfwords = (SIZEOF(.iwram) + 1) / 2; - . = __iwram_rom_start + (__iwram_data_end - __iwram_data_start); - - __ewram_rom_start = .; .ewram : { - __ewram_data_start = ABSOLUTE(.); - *(.ewram .ewram.*); . = ALIGN(4); *(.data .data.*); . = ALIGN(4); - - __ewram_data_end = ABSOLUTE(.); } > ewram AT>rom + __ewram_data_start = ADDR(.ewram); + __ewram_rom_start = LOADADDR(.ewram); + __ewram_rom_length_halfwords = (SIZEOF(.ewram) + 1) / 2; .bss : { *(.bss .bss.*); @@ -66,12 +64,6 @@ SECTIONS { __iwram_end = ABSOLUTE(.); } > iwram - __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; - __iwram_rom_length_halfwords = (__iwram_rom_length_bytes + 1) / 2; - - __ewram_rom_length_bytes = __ewram_data_end - __ewram_data_start; - __ewram_rom_length_halfwords = (__ewram_rom_length_bytes + 1) / 2; - .shstrtab : { *(.shstrtab) }