gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > the bss section

#149451 - bpoint - Sun Jan 20, 2008 9:36 am

Hello all,

I made a post over at the devkitPro forums asking some questions about the GBA's bss section, but it seems the user base over there isn't quite as big as it is here... :)

In any case, I'm still looking for the answer to any of these three questions:

1) Is there any specific reason why .bss is located in iwram instead of ewram?
2) Is it possible to relocate the .bss section from iwram to ewram? I presume I need to change the gba_cart.ld file, but I'm not exactly sure what I'd need to change and where.
3) Are there any side-effects with moving .bss into ewram? Will its location conflict with malloc() and/or my stack?

Any takers? Thanks!

#149458 - tepples - Sun Jan 20, 2008 2:15 pm

For one thing, IWRAM is much faster than EWRAM on the GBA because the ARM7 doesn't have a cache. The DS link script gets away with putting .data and .bss in EWRAM because the ARM9 caches EWRAM.

If you want a big block of statically allocated slow memory, use section .sbss to put it in EWRAM. But then you won't be able to use an appended data file (e.g. GBFS) because it will overlap section .sbss.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#149474 - bpoint - Sun Jan 20, 2008 6:54 pm

tepples wrote:
For one thing, IWRAM is much faster than EWRAM on the GBA because the ARM7 doesn't have a cache. The DS link script gets away with putting .data and .bss in EWRAM because the ARM9 caches EWRAM.

Yeah, I know IWRAM is faster, but having all static data put into IWRAM is blocking me from putting all of the code from my sound engine (and in the future my 3D rendering code as well) I want in there, since space is rather limited. Since malloc() returns a pointer to EWRAM memory anyway, it seems like that it wouldn't hurt much to have both .data and .bss go into EWRAM. Or am I wrong about that?

tepples wrote:
If you want a big block of statically allocated slow memory, use section .sbss to put it in EWRAM. But then you won't be able to use an appended data file (e.g. GBFS) because it will overlap section .sbss.

The problem is gcc is automatically putting all of my static symbols into .bss. I'd have to put __attribute__(section (".sbss")) after every static variable in my source code... which is not going to be fun, hence the reason I wanted to know if I could change the linker script to move everything into EWRAM for me. I already have my own methods for accessing appended file data to the ROM, so GBFS isn't an issue, but on the NDS, I was planning on using libfat. Is there anything I should be aware of regarding this on NDS?