I've disassembled some C/C++ codes and realized the stack boundary is specified at beginning of a procedure, somehow like this :
1. push ebp
2. mov ebp , esp
3. sub esp , <power> ; <power> is specified by mpreferred-stack-boundary=2^power
The above code is used to create stack frames, But What I need to know is why this subtract is used, Cause the stack grows down (by using push for local variables) and such the subtract causes :
---------------------------- ^
by sub esp,<power> <---- esp |
. |
. |
. |
---------------------------- |
esp <---- esp |
---------------------------- |
ret address |
---------------------------- |
The above picture shows that.So when in the rest of code if you have such the following codes:
push var1
It should be taken at the top of it so it looks like this :
-----------------------------
var1 (4 byte)
-----------------------------^
by sub esp,<power> <---- esp |
. |
. |
. |
---------------------------- |
esp <---- esp |
---------------------------- |
ret address |
---------------------------- |
So the space between esp and var1 is going to be free without any use ? that's what I want to know.