rgbds icon indicating copy to clipboard operation
rgbds copied to clipboard

Add a way to force two sections to be in the same bank

Open AntonioND opened this issue 7 years ago • 10 comments

As discussed here: https://github.com/rednex/rgbds/issues/133

This could either be done in source code or by using the linkerscript.

SECTION "Code", ROMX
...
SECTION "Data", ROMX, BANK["Code"]

This would allow to have sections with different alignments if needed.

AntonioND avatar Feb 23 '18 01:02 AntonioND

Seems useful overall. I wonder how this could be done linkerscript-side, though.

aaaaaa123456789 avatar Feb 23 '18 01:02 aaaaaa123456789

Linkerscripts can already do this, since they specify sections bank per bank. If we wanted to remove the restriction of having to specify the bank, then your suggestion of writing only ROMX instead of ROMX $2A seems like a good idea, imo.

ISSOtm avatar Feb 23 '18 02:02 ISSOtm

The problem is that linkerscripts force an order to the sections, but the source code solution doesn't.

AntonioND avatar Feb 23 '18 09:02 AntonioND

Nice, I can certainly think of times in the past when I could’ve used this!

Does it matter that this solution doesn’t specify the order? After all, this isn’t something we usually enforce, unless if you use a linkerscript or manually specify a memory address.

BenHetherington avatar Feb 23 '18 23:02 BenHetherington

I was thinking mostly about the gap that the alignment may leave between the sections. I'd like to give flexibility to the linker to place them however they fit.

AntonioND avatar Feb 23 '18 23:02 AntonioND

It would be particularly useful for sections with large alignment requirements (I've used as high as $200!). The linker might even be able to fit another section in the gap.

On 23 Feb 2018 20:58, "AntonioND" [email protected] wrote:

I was thinking mostly about the gap that the alignment may leave between the sections. I'd like to give flexibility to the linker to place them however they fit.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rednex/rgbds/issues/244#issuecomment-368173635, or mute the thread https://github.com/notifications/unsubscribe-auth/AF2FfDvC5j5QNEgoc1Ua00OVkPaig5faks5tX1CVgaJpZM4SQP0k .

aaaaaa123456789 avatar Feb 24 '18 01:02 aaaaaa123456789

Sorry for necrobumping this, but if it isn't doesn't make the feature too complex, it'd be nice to have a BANK["Code" + 1] syntax.

mid-kid avatar Apr 24 '19 10:04 mid-kid

Can we consider this fixed by #517? Make two SECTION FRAGMENTs with the same name, and they'll be allocated together. It's not perfect, because the constraints are solved globally on the section instead of at each fragment boundary (should that be considered a bug?), but it fulfills the use case.

ISSOtm avatar Jul 22 '20 11:07 ISSOtm

Can we consider this fixed by #517? Make two SECTION FRAGMENTs with the same name, and they'll be allocated together. It's not perfect, because the constraints are solved globally on the section instead of at each fragment boundary (should that be considered a bug?), but it fulfills the use case.

From #655, it seems like the answer is "no".

aaaaaa123456789 avatar Dec 21 '20 16:12 aaaaaa123456789

it'd be nice to have a BANK["Code" + 1] syntax

Another use case brought up for this is INCBINning a large binary file into multiple sequential banks.

Rangi42 avatar Mar 08 '24 15:03 Rangi42