Fixed semihosting for AArch64 when heapinfo parameters are not provided by debugger

This commit is contained in:
Alexander Fedotov
2017-10-11 14:52:20 +03:00
committed by Corinna Vinschen
parent 56e494c074
commit f6ef29c48f
2 changed files with 59 additions and 26 deletions

View File

@@ -625,6 +625,9 @@ _getpid (int n __attribute__ ((unused)))
return 1;
}
/* Heap limit returned from SYS_HEAPINFO Angel semihost call. */
ulong __heap_limit __attribute__ ((aligned (8))) = 0xcafedead;
caddr_t
_sbrk (int incr)
{
@@ -637,7 +640,9 @@ _sbrk (int incr)
prev_heap_end = heap_end;
if (heap_end + incr > stack_ptr)
if ((heap_end + incr > stack_ptr)
/* Honour heap limit if it's valid. */
|| ((__heap_limit != 0xcafedead) && (heap_end + incr > __heap_limit)))
{
/* Some of the libstdc++-v3 tests rely upon detecting
out of memory errors, so do not abort here. */