GBA Overlay sections [Solution]

Post Reply
g012
Posts: 3
Joined: Sat Mar 07, 2015 8:23 pm

GBA Overlay sections

Post by g012 » Sun Jan 03, 2016 1:11 am

Hello,

I'm trying to use overlay sections. However when I do so, it seems the .pad section doesn't count them and overlaps them. Here's what I get in the map file:

Code: Select all

.iwram0         0x030036ac       0x24 load address 0x080ca818
 *(.iwram0)
 .iwram0        0x030036ac       0x14 t_overlay.thumb.o
                0x030036ac                Overlay0
 .iwram0.__stub
                0x030036c0        0xc linker stubs
                0x030036cc                . = ALIGN (0x4)
                0x080ca818                PROVIDE (__load_start_iwram0, LOADADDR (.iwram0))
                0x080ca83c                PROVIDE (__load_stop_iwram0, (LOADADDR (.iwram0) + SIZEOF (.iwram0)))

.iwram1         0x030036ac       0x24 load address 0x080ca83c
 *(.iwram1)
 .iwram1        0x030036ac       0x14 t_overlay.thumb.o
                0x030036ac                Overlay1
 .iwram1.__stub
                0x030036c0        0xc linker stubs
                0x030036cc                . = ALIGN (0x4)
                0x080ca83c                PROVIDE (__load_start_iwram1, LOADADDR (.iwram1))
                0x080ca860                PROVIDE (__load_stop_iwram1, (LOADADDR (.iwram1) + SIZEOF (.iwram1)))

.rel.dyn        0x030036d0        0x0 load address 0x080ca860
 .rel.iplt      0x030036d0        0x0 d:/softs/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/gba_crt0.o

.iwram2         0x030036ac        0x0
 *(.iwram2)
                0x030036ac                . = ALIGN (0x4)
                [!provide]                PROVIDE (__load_start_iwram2, LOADADDR (.iwram2))
                [!provide]                PROVIDE (__load_stop_iwram2, (LOADADDR (.iwram2) + SIZEOF (.iwram2)))

Code: Select all

.pad            0x02001738        0x8 load address 0x080ca83c
                0x02001738        0x4 LONG 0x52416b64
                0x0200173c        0x4 LONG 0x4d
                0x02001740                . = ALIGN (0x4)
                0x080ca844                __rom_end__ = (__pad_lma + SIZEOF (.pad))
And of course the linker complains. How can I fix this ?
Thank you.

g012
Posts: 3
Joined: Sat Mar 07, 2015 8:23 pm

GBA Overlay sections [Solution]

Post by g012 » Sun Jan 03, 2016 12:56 pm

Hi,

I create a new topic since the previous one hasn't been approved yet.
I've managed to get overlays working by changing the linkscript:

Old:

Code: Select all

	__iwram_overlay_end = . ;
	__ewram_lma = __iwram_overlay_lma + (__iwram_overlay_end - __iwram_overlay_start) ;
New:

Code: Select all

    __iwram_overlay_size = __load_stop_iwram0 - __load_start_iwram0 + __load_stop_iwram1 - __load_start_iwram1 + __load_stop_iwram2 - __load_start_iwram2 + __load_stop_iwram3 - __load_start_iwram3 + __load_stop_iwram4 - __load_start_iwram4 + __load_stop_iwram5 - __load_start_iwram5 + __load_stop_iwram6 - __load_start_iwram6 + __load_stop_iwram7 - __load_start_iwram7 + __load_stop_iwram8 - __load_start_iwram8 + __load_stop_iwram9 - __load_start_iwram9;
    __ewram_lma = __iwram_overlay_lma + __iwram_overlay_size;
According to the doc ftp://ftp.gnu.org/old-gnu/Manuals/ld-2. ... ld_22.html, . after OVERLAY is using the max size of all sections, not the sum of all sizes. I believe the current linkscript is buggy.
Could something along these lines be integrated into the next update ?
Thanks !

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest