Home > Blockchain >  Heap Memory Allocation in ARM64 Assembly without the C Standard Library
Heap Memory Allocation in ARM64 Assembly without the C Standard Library

Time:07-16

I'm trying to find a way to do heap memory allocation in armv8-a assembly, and after looking through syscall tables and trying to look at the Linux Programmer's Manual I can't find any way to allocate and de-allocate memory at runtime without using malloc and free from the c standard library.

I've looked at brk() but that doesn't appear to have any way to de-allocate memory.

CodePudding user response:

mmap with MAP_ANONYMOUS is preferred to sbrk/brk for most purposes in modern programs. Use munmap to free.

By the way, brk can deallocate memory; simply pass an address lower than the current break point. But this does limit you to freeing in a last-in-first-out fashion.

  • Related