Page 1 of 1

Reducing libgbas IWRAM footprint

Posted: Sat Jan 12, 2019 2:26 pm
by bim
Looking at the .map file of my GBA .elf with amap I see several blocks of IWRAM being allocated by libgba. I attached an amap screenshot. Is there any way to reduce that? Heap management could rather be in EWRAM and why a mutex? I probably only need the headers and the interrupt stuff libgba offers. What can I do?
On a tangent: Is there a way to use MaxMOD without libgba?

Re: Reducing libgbas IWRAM footprint

Posted: Wed Jan 23, 2019 1:23 pm
by WinterMute
Traditionally on GBA .data & .bss go in iwram, this is a function of the linkscript & has very little to do with libgba. Bear in mind that EWRAM is 16bit access & is much slower than IWRAM so changing it is likely to have a performance impact.

devkitARM also builds code for platforms where threading is possible, thus there are locks in malloc which do nothing on GBA. If you're that concerned then perhaps you should manage memory yourself.

Yes, it's possible to use maxmod without libgba, I've provided sample code that uses libtonc at https://devkitpro.org/viewtopic.php?f=37&t=8830

Re: Reducing libgbas IWRAM footprint

Posted: Thu Jan 24, 2019 11:42 am
by bim
Your right. I've done just that. I removed libgba and also got rid of memory management using the GCC options:
-Wl,--wrap=malloc,--wrap=free,--wrap=alloc,--wrap=calloc
All allocations are redirected to my internal methods, which I need anyway. This gives me more control over allocations, but still static stuff can be allocated in IWRAM/EWRAM if needed.

Btw. Does MaxMODs IWRAM footprint depend on the number of channels? It uses ~7-8kB of IWRAM. Could I reduce that?