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: Tamar Christina <Tamar dot Christina at arm dot com>
- To: "nickc at redhat dot com" <nickc at redhat dot com>, Claudio Scordino <claudio at evidence dot eu dot com>, "newlib at sourceware dot org" <newlib at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Wed, 8 Aug 2018 11:09:37 +0000
- Subject: RE: Bare-metal: how to specify the heap size in the linker script
- References: <f2277349-fed4-4546-f2a8-62ff31a58106@evidence.eu.com> <7a2a7db4-bd30-124d-3f03-6b8e03c4e53d@redhat.com> <AM4PR08MB0737675857966C7B575413D3FF260@AM4PR08MB0737.eurprd08.prod.outlook.com>
Forwarding to list too. Sorry for the dup.
> -----Original Message-----
> From: Tamar Christina
> Sent: Wednesday, August 8, 2018 12:09
> To: 'Nick Clifton' <nickc@redhat.com>; Claudio Scordino
> <claudio@evidence.eu.com>; newlib@sourceware.org
> Subject: RE: Bare-metal: how to specify the heap size in the linker script
>
> Hi Claudio,
>
> > -----Original Message-----
> > From: newlib-owner@sourceware.org <newlib-owner@sourceware.org>
> On
> > Behalf Of Nick Clifton
> > Sent: Wednesday, August 8, 2018 11:58
> > To: Claudio Scordino <claudio@evidence.eu.com>;
> newlib@sourceware.org
> > Subject: Re: Bare-metal: how to specify the heap size in the linker
> > script
> >
> > 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...
>
> You didn't say if you're using semihosting or not
>
> If you're using semihosting you can specify the limits in the SYS_HEAPINFO
> return values
> https://developer.arm.com/docs/100863/latest/semihosting-
> operations/sys_heapinfo-0x16
>
> if you're not, then what Nick suggests is the way to go in your _sbrk
> implementation.
>
> Regards,
> Tamar
>
> >
> > Cheers
> > Nick
> >