I’m experimenting with assembly language and wrote a program which prints 2 hardcoded bytes into stdout. Here it is:
section .text global _start _start: mov eax, 0x0A31 mov [val], eax mov eax, 4 mov ebx, 1 mov ecx, val mov edx, 2 int 0x80 mov eax, 1 int 0x80 segment .bss val resb 1; <------ Here
Note that I reserved only 1 byte inside the bss segment, but actually put 2 bytes (charcode for
newline symbol) into the memory location. And the program worked fine. It printed
1 character and then
But I expected segmentation fault. Why isn’t it occured. We reserved only 1 byte, but put 2.