diff --git a/platforms/qemu_integratorcp/syscalls.c b/platforms/qemu_integratorcp/syscalls.c index 97295a7..1467d58 100644 --- a/platforms/qemu_integratorcp/syscalls.c +++ b/platforms/qemu_integratorcp/syscalls.c @@ -55,12 +55,13 @@ int _read(int file, char *ptr, int len) { char *heap_end = 0; caddr_t _sbrk(int incr) { - extern char heap_low; /* Defined by the linker */ + extern char end; /* Defined by the linker */ extern char heap_top; /* Defined by the linker */ + static char *heap_end; char *prev_heap_end; if (heap_end == 0) { - heap_end = &heap_low; + heap_end = &end; } prev_heap_end = heap_end; diff --git a/platforms/qemu_integratorcp/system.ld b/platforms/qemu_integratorcp/system.ld index 4de00a5..6ee3586 100644 --- a/platforms/qemu_integratorcp/system.ld +++ b/platforms/qemu_integratorcp/system.ld @@ -57,11 +57,6 @@ SECTIONS _end_bss = .; __bss_end__ = . ; - . = ALIGN(8); - heap_low = .; /* for _sbrk */ - . = . + 0x10000; /* 64kB of heap memory */ - heap_top = .; /* for _sbrk */ - . = ALIGN(256); .stack : { @@ -95,3 +90,5 @@ SECTIONS __end__ = .; _end = .; PROVIDE(end = .); + +heap_top = ORIGIN(sram) + LENGTH(sram) - 4;