I’ve updated the crt0 and linker script to enable the use of the sda attribute when declaring global/static variables. This enables global/static variables to be accessed in a single instruction using the global pointer register (r4).
__attribute((sda)) int foo= 42;
The updated crt0 and linker script are attached. Let me know if you have any problems/suggestions.
There’s also a compiler option -msda=n which puts all global/static variables of size n bytes or less into the small data area. The maximum size of the sda is 64K, the same as WRAM. However, when using this option the compiler rather unhelpfully creates a .rosdata section which I’m not quite sure what to do about yet, so use the sda attribute instead for now.
How exactly do I use the crt0 script? I added the linker script to the makefile and it seems like it is used now. However, I have no idea how to use the crt0 script…
After writing some 1000 lines of code I get this linker error:
v810-gcc -Tvb.ld -Wall -nodefaultlibs -mv810 -xc -o fishbone.o fishbone.c
/usr/local/v810/bin/ld: address 0x501022c of fishbone.o section .data is not within region wram
collect2: ld returned 1 exit status
make: *** [fishbone.o] Error 1
I’m not an expert on this, but it looks like you have used up all the WRAM (Work RAM), which is the RAM available for use by the game. It is 64K in size and accessible from 0x05000000 to 0x0500FFFF, then it is mirrored 255 times. Do you have any large static arrays in the code?
HorvatM wrote:
I’m not an expert on this, but it looks like you have used up all the WRAM (Work RAM), which is the RAM available for use by the game. It is 64K in size and accessible from 0x05000000 to 0x0500FFFF, then it is mirrored 255 times. Do you have any large static arrays in the code?
I just had a look into the linker script and saw the same thing. I do have some larger array. I guess making them ‘const’ would solve the problem. I had some problems with large const arrays in the past so I tried avoiding them. Just out of curiosity: Why is the wram mirrored 255 times?