I know that during a function call, the EBP register is pointing to the first value that the called function pushes onto the stack. But when the main function is called for the first time, what is the EBP register pointing to? Is it the first local variable that is pushed onto the stack by the main function?
It is undefined where ebp
points to when the function is entered. Function prologue (which is part of the function) makes ebp
point to stack frame, although the prologue can be omitted if it is not needed or can do anything else with ebp
as long as it restores the value when returning. main
is not different in this.