I have this little program written in x64 assembly:
xor rdx,rdx
push rdx ;null terminator
push 0x41414141 ;AAAA
push 0x45454545 ;EEEE
mov rsi,rsp ;pointer to the string
mov rdi,1 ;output file: stdout
mov rdx,8 ;buffer size 8
mov rax,1 ;write syscall
syscall
As you can see, I push eight bytes to the stack and when I call write with buffer size 8, I am expecting to see EEEEAAAA
but the output is EEEE
. However, when I set the buffer size rdx
to 12, I can see the full string EEEEAAAA
. What is between those four-byte blocks? Aren't they ought to be adjacent?