I'm using e2studio with RX 4.8.4.201803-GNURX tools, on an RX71 with 512KB of RAM memory. The map file of the project shows correctly RAM ending at 0x80000 as shown below:
Memory Configuration
Name Origin Length AttributesRAM 0x00000000 0x00080000ROM 0xffc00000 0x00400000OFS 0x00120000 0x00000100*default* 0x00000000 0xffffffff
The linker script also has the correct ram at 0 with a size of 524288 (0x80000) bytes.
MEMORY{ RAM : ORIGIN = 0x0, LENGTH = 524288 ROM : ORIGIN = 0xFFC00000, LENGTH = 4194304 OFS : ORIGIN = 0x120000, LENGTH = 256}
Using malloc test code of:
struct kilo{ //test 128byte structures to allocate struct kilo *next; char dummy[124];};
...
current = (struct kilo *) malloc(sizeof(struct kilo));counter = 0; do { //allocate ALL the available memory 128 bytes at a time counter++; current->next = (struct kilo *)malloc(sizeof(struct kilo)); current = current->next;
if(current > 0x7ff80) printf("WTF? %x\n",current);} while (current);
A NULL value should be returned for allocation requests above 0x7ff80 and the do loop should exit without triggering the printf line. However the above test prints "WTF 7ffac". There is not enough remaining RAM above 0x7ffac to store the next 128byte structure. The next loop itteration does fail.
My question is why doesn't malloc know that it is out of memory? What configuration setting tells malloc where RAM memory ends?
Any help would be appreciated. thank you in advance!
Regards
Dan