I am trying to learn about how the stack works so I wrote a pretty simple C program to run through GDB and examine the stack:
int main(int argc, char **argv)
{
char buf[100];
strcpy(buf, argv[1]);
}
I compiled the program and set a breakpoint in GDB for the beginning of the main() function. My expectation of how the stack should look at this point in execution is:
lower memory addresses... | ebp = esp = stack frame pointer | return address | argv | arc | ...higher memory addresses
As the program progresses, the stack would increase in the direction of the lower memory addresses (allocating 100 bytes for the bur local variable)
Looking at GDB, that does not seem to be the case.
- The stack frame appears to be at 0xbffff048
- The return address appears to be a 0xbffff04c
- But it looks like argc (value of 2) is at 0xbffff050
Where is argv? Can anyone take a look at my screenshot and help me make heads or tails of this?
Thank you!