Add ability for a segment to be placed in RAM directly after another segment
Currently, there is no way to just have one segment be placed directly after another segment in ram, which is necessary for shiftability. Ideally, this wouldn't be limited to just starting after the immediately preceding segment, as several overlays may share an address in RAM that comes from the end of some other segment for example.
@Mr-Wiseguy how would this look in the linker? I'll try to add it today
As an example from Paper Mario, splat currently generates linker script that looks like this for the pause section:
pause_VRAM = ADDR(.pause);
.pause 0x80242BA0 : AT(pause_ROM_START) SUBALIGN(8)
That segment is placed in both RAM and ROM directly after the ui_images one, so the yaml should be able to specify that so that changing the size or address of ui_images changes the start address of pause. This could look like so (tested and still gets OK):
pause_VRAM = ADDR(.pause);
.pause ADDR(.ui_images) + SIZEOF(.ui_images) : AT(pause_ROM_START) SUBALIGN(8)
This allows segment RAM addresses to be shifted, though there's more to be done for ROM addresses to be shiftable as well. Currently, splat generates many manual __romPos assignments in the linker script. Allowing for ROM address shiftability instead requries that __romPos is incremented by segment sizes instead of being set to fixed values. That would be something along the lines of changing
ui_images_ROM_END = 0x135EE0;
__romPos = 0x135EE0;
__romPos = 0x135EE0;
. = __romPos;
pause_ROM_START = __romPos;
pause_VRAM = ADDR(.pause);
.pause ADDR(.ui_images) + SIZEOF(.ui_images) : AT(pause_ROM_START) SUBALIGN(8)
to
__romPos += SIZEOF(.ui_images);
ui_images_ROM_END = __romPos;
. = __romPos;
pause_ROM_START = __romPos;
pause_VRAM = ADDR(.pause);
.pause ADDR(.ui_images) + SIZEOF(.ui_images) : AT(pause_ROM_START) SUBALIGN(8)
The placement of a segment after another in RAM needs to be decoupled from its placement in ROM, since several segments may share a start address after the end of a previous segment (making them overlays). ROM address placement can be driven directly from the yaml ordering since that is already ordered by ROM address. For example, the filemenu segment which is in the ROM directly after pause shares a RAM start address, so it should be specified in the yaml that both start after the ui_images segment.
A small note: in order for that __romPos += SIZEOF(...); line to work, the issue of bss being included in the rom must be solved and the bss must be moved out of that linker section. Otherwise, it will only work for segments that have no bss, as it'll include the bss in the size of the linker section.
A small note: in order for that
__romPos += SIZEOF(...);line to work, the issue of bss being included in the rom must be solved and the bss must be moved out of that linker section. Otherwise, it will only work for segments that have no bss, as it'll include the bss in the size of the linker section.
Done in https://github.com/ethteck/splat/commit/e1abb4ece0b948a5e7d8dcb2c3eb9e0055b2b330 :) I'll start working on the above changes soon