title: Finding argv address in GDB
body: <p>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:</p>
  
  <pre><code>int main(int argc, char **argv)
  {
      char buf[100];
      strcpy(buf, argv[1]);
  }
  </code></pre>
  
  <p>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:</p>
  
  <p>lower memory addresses... | ebp = esp = stack frame pointer | return address | argv | arc | ...higher memory addresses</p>
  
  <p>As the program progresses, the stack would increase in the direction of the lower memory addresses (allocating 100 bytes for the bur local variable)</p>
  
  <p>Looking at GDB, that does not seem to be the case.</p>
  
  <ul>
  <li>The stack frame appears to be at 0xbffff048</li>
  <li>The return address appears to be a 0xbffff04c</li>
  <li>But it looks like argc (value of 2) is at 0xbffff050</li>
  </ul>
  
  <p><strong>Where is argv?  Can anyone take a look at my screenshot and help me make heads or tails of this?</strong></p>
  
  <p>Thank you!</p>
  
  <p><a href="https://i.stack.imgur.com/FBHP7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FBHP7.png" alt="Screenshot of GDB running"></a></p>