The linker created _end symbol does not have the right bounds, so
don't try to reuse leftover memory at the end of the .data section.
# pragma GCC visibility push(hidden)
#endif
#include <assert.h>
+#include <stdint.h>
#include <string.h>
#include <ldsodefs.h>
#include <malloc/malloc-internal.h>
void *
__minimal_malloc (size_t n)
{
+#ifndef __CHERI_PURE_CAPABILITY__
if (alloc_end == 0)
{
/* Consume any unused space in the last page of our data segment. */
+ GLRO(dl_pagesize) - 1)
& ~(GLRO(dl_pagesize) - 1));
}
+#endif
/* Make sure the allocation pointer is ideally aligned. */
- alloc_ptr = (void *) 0 + (((alloc_ptr - (void *) 0) + MALLOC_ALIGNMENT - 1)
+ alloc_ptr = (void *)(((uintptr_t)alloc_ptr + (MALLOC_ALIGNMENT - 1))
& ~(MALLOC_ALIGNMENT - 1));
if (alloc_ptr + n >= alloc_end || n >= -(uintptr_t) alloc_ptr)