Got an interesting problem. I have a function void F() , that is, it does not accept any parameters. But in its assembly code this is the beginning:
1: mov rax, rsp 2: mov qword ptr [rax+8], rbx 3: push rdi ... I am surprised at the second line. If we do not pass parameters, why does the function allow itself to overwrite the value of [rsp+8] . The address of [rsp] contains the return address, but then, after all, someone else’s stack frame, and this function overwrites the value. Further, because of this, I get an error. Why is there such a team and what can be done?
I will add that this is an educational task and within its framework I form a stack manually (I write down return addresses, function parameters, etc.). In the Debug version, everything is fine, in Release, here in this place the value I need is overwritten.
gccthis is the-Sswitch. - PinkTux