I am trying to write data to space reserved in the .bss section of my code (NASM/Linux x64). Why do I get segmentation fault in this small code sample?
section .bss
big_space: resb 80 ; reserve 80 bytes
section .text
global _start
_start:
mov rbx, [rel big_space] ; I use rel here otherwise I get linking error
mov [rbx], byte 'H' ; if I comment this, no segfault
mov rax, 60 ; exits with code 0
mov rdi, 0
syscall
Isn't the address of big_space supposed to be reserved for my program? As far as I understand, the problematic instruction is trying to copy 'H' (as an 8-bit value) to the address in RBX. This address, as per the first instruction, I expect to be the address of my buffer big_space. What went wrong?