abort() is now called if a heap mapping fails

This commit is contained in:
2022-01-09 20:01:12 +00:00
parent 794311a0d5
commit 51cebdae2d

View File

@@ -1,8 +1,12 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <magenta/vmo.h> #include <magenta/vmo.h>
#include <magenta/bootstrap.h> #include <magenta/bootstrap.h>
#include <magenta/errors.h>
#include <magenta/misc.h>
#include <magenta/vmar.h> #include <magenta/vmar.h>
#define ROUND_UP(x, b) x += (b) - ((x) % (b)) #define ROUND_UP(x, b) x += (b) - ((x) % (b))
@@ -56,9 +60,15 @@ void *__crt_heap_extend(size_t sz)
mx_vmar_bounds(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), &vmar_base, NULL); mx_vmar_bounds(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), &vmar_base, NULL);
size_t offset = heap_end - vmar_base; size_t offset = heap_end - vmar_base;
mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT), mx_status_t err = mx_vmar_map(mx_bootstrap_handle_get(MX_B_VMAR_ROOT),
MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC, MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC,
offset, heap_vmo, heap_sz, sz, &alloc_base); offset, heap_vmo, heap_sz, sz, &alloc_base);
if (err != MX_OK) {
printf("cannot map extended heap: %s\n", mx_status_to_string(err));
abort();
}
heap_sz += sz; heap_sz += sz;
void *out = (void *)heap_end; void *out = (void *)heap_end;