#39714 - Darkain - Mon Apr 11, 2005 6:17 pm
I was playing around w/ the addresses that malloc returned:
I was wondering why using malloc (or new which calls malloc) was failing for anything that was about 12kb or larger.
malloc starts allocating things at offset about 0x1000, and the ARM9 bin is copied to an offset of 0x4000. Because of this, we are limited to 12kb of RAM before we start over-writing the code segment copied into RAM.
i'm no expert on how the crt0 is setup for the ARM9, but *something* has to change. if the starting address for memory allocation has to be static, at least make it at offset 0x100000, which is exactly 1MB into RAM. this would allow for 1MB ARM9.bin, 2.5MB for RAM, and 512KB for ARM7.bin
[EDIT]
http://cvs.sourceforge.net/viewcvs.py/devkitpro/buildscripts/dka-crtls/ds_arm9.ld
Thanx to WntrMute, the bug is now gone. There should be no more problems with malloc/new (untill you try to use more than 3.5MB of RAM :P)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS
Code: |
0x02001010 - first malloc
0x020010C0 - class instance (new) 0x02001100 - buffer instance (malloc, 0x16000 bytes, end address 0x02017100, right thru MAIN and other functions) 0x02034FBB - ROM DATA1 0x02033ECB - ROM DATA2 0x0200811C - MAIN function pointer |
I was wondering why using malloc (or new which calls malloc) was failing for anything that was about 12kb or larger.
malloc starts allocating things at offset about 0x1000, and the ARM9 bin is copied to an offset of 0x4000. Because of this, we are limited to 12kb of RAM before we start over-writing the code segment copied into RAM.
i'm no expert on how the crt0 is setup for the ARM9, but *something* has to change. if the starting address for memory allocation has to be static, at least make it at offset 0x100000, which is exactly 1MB into RAM. this would allow for 1MB ARM9.bin, 2.5MB for RAM, and 512KB for ARM7.bin
[EDIT]
http://cvs.sourceforge.net/viewcvs.py/devkitpro/buildscripts/dka-crtls/ds_arm9.ld
Thanx to WntrMute, the bug is now gone. There should be no more problems with malloc/new (untill you try to use more than 3.5MB of RAM :P)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS