This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Bare-metal: how to specify the heap size in the linker script
- From: Nick Clifton <nickc at redhat dot com>
- To: Claudio Scordino <claudio at evidence dot eu dot com>, newlib at sourceware dot org
- Date: Wed, 8 Aug 2018 11:58:10 +0100
- Subject: Re: Bare-metal: how to specify the heap size in the linker script
- References: <f2277349-fed4-4546-f2a8-62ff31a58106@evidence.eu.com>
Hi Claudio,
> However, this way there is no way of checking if the heap has reached the maximum value (after which we get stack corruption).
It sounds like you need to check the current heap top against the
current stack pointer. Take a look in newlib/libgloss/aarch64/syscalls.c
at the implementation of the _sbrk() system call. This uses a magic
asm("sp") statement to get hold of the stack pointer...
Cheers
Nick