From cd000ca76727ab67274368a9c2e4aad8f3d28469 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 30 Jul 2022 17:21:46 +0100 Subject: [PATCH] use the end of all assigned iwram data --- agb/gba.ld | 1 + agb/gba_mb.ld | 1 + agb/src/agb_alloc/mod.rs | 4 ++-- book/games/pong/gba.ld | 1 + book/games/pong/gba_mb.ld | 1 + examples/hyperspace-roll/gba.ld | 1 + examples/hyperspace-roll/gba_mb.ld | 1 + examples/the-hat-chooses-the-wizard/gba.ld | 1 + examples/the-purple-night/gba.ld | 1 + examples/the-purple-night/gba_mb.ld | 1 + template/gba.ld | 1 + template/gba_mb.ld | 1 + 12 files changed, 13 insertions(+), 2 deletions(-) diff --git a/agb/gba.ld b/agb/gba.ld index cd74016a..5665df24 100644 --- a/agb/gba.ld +++ b/agb/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/agb/gba_mb.ld b/agb/gba_mb.ld index 238b5c4c..1547960f 100644 --- a/agb/gba_mb.ld +++ b/agb/gba_mb.ld @@ -63,6 +63,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/agb/src/agb_alloc/mod.rs b/agb/src/agb_alloc/mod.rs index 310096ea..763b9705 100644 --- a/agb/src/agb_alloc/mod.rs +++ b/agb/src/agb_alloc/mod.rs @@ -68,12 +68,12 @@ fn alloc_error(layout: Layout) -> ! { fn iwram_data_end() -> usize { extern "C" { - static __iwram_data_end: usize; + static __iwram_end: usize; } // TODO: This seems completely wrong, but without the &, rust generates // a double dereference :/. Maybe a bug in nightly? - (unsafe { &__iwram_data_end }) as *const _ as usize + 0x200 + (unsafe { &__iwram_end }) as *const _ as usize } fn data_end() -> usize { diff --git a/book/games/pong/gba.ld b/book/games/pong/gba.ld index cd74016a..5665df24 100644 --- a/book/games/pong/gba.ld +++ b/book/games/pong/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/book/games/pong/gba_mb.ld b/book/games/pong/gba_mb.ld index 238b5c4c..1547960f 100644 --- a/book/games/pong/gba_mb.ld +++ b/book/games/pong/gba_mb.ld @@ -63,6 +63,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/examples/hyperspace-roll/gba.ld b/examples/hyperspace-roll/gba.ld index cd74016a..5665df24 100644 --- a/examples/hyperspace-roll/gba.ld +++ b/examples/hyperspace-roll/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/examples/hyperspace-roll/gba_mb.ld b/examples/hyperspace-roll/gba_mb.ld index 238b5c4c..1547960f 100644 --- a/examples/hyperspace-roll/gba_mb.ld +++ b/examples/hyperspace-roll/gba_mb.ld @@ -63,6 +63,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/examples/the-hat-chooses-the-wizard/gba.ld b/examples/the-hat-chooses-the-wizard/gba.ld index cd74016a..5665df24 100644 --- a/examples/the-hat-chooses-the-wizard/gba.ld +++ b/examples/the-hat-chooses-the-wizard/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/examples/the-purple-night/gba.ld b/examples/the-purple-night/gba.ld index cd74016a..5665df24 100644 --- a/examples/the-purple-night/gba.ld +++ b/examples/the-purple-night/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/examples/the-purple-night/gba_mb.ld b/examples/the-purple-night/gba_mb.ld index 238b5c4c..1547960f 100644 --- a/examples/the-purple-night/gba_mb.ld +++ b/examples/the-purple-night/gba_mb.ld @@ -63,6 +63,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/template/gba.ld b/template/gba.ld index cd74016a..5665df24 100644 --- a/template/gba.ld +++ b/template/gba.ld @@ -65,6 +65,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start; diff --git a/template/gba_mb.ld b/template/gba_mb.ld index 238b5c4c..1547960f 100644 --- a/template/gba_mb.ld +++ b/template/gba_mb.ld @@ -63,6 +63,7 @@ SECTIONS { .bss : { *(.bss .bss.*); . = ALIGN(4); + __iwram_end = ABSOLUTE(.); } > iwram __iwram_rom_length_bytes = __iwram_data_end - __iwram_data_start;