I'm trying to allocate 0x4000
bytes in the heap by uses the brk system call. However when doing this, trying to set anything after 0x999
segfaults. This is what I'm using:
global _start
section .data
heapStart: dq 0 ; Start of the heap
section .text
_start:
mov rax, 12 ; Heap call
mov rdi, 0
syscall ; Get the base pointer
mov QWORD [heapStart], rax
lea rdi, [rax + 0x4000]
mov rax, 12
syscall ; Allocate 8000 bytes
mov rdi, heapStart
mov BYTE [rdi + 0x1000], 'b' ; Errors "SIGSEGV"
mov rax, 60 ; exit
mov rdi, 0 ; error code
syscall
Why does this happen? And how can I set bytes over 0x999
?