title: Function calling convention Powerpc vs Intel
body: <p>I need information on the following:</p>
  
  <p>How powerpc and intel processors allocate stack when calling a function?
  - On what basis is stack size determined in each case i.e powerpc and intel x86 processors
  - Where are arguments and return addresses stored on stack.</p>
  
  <p>Basically I need to stack layout in each case.</p>
  
  <p>I have a situation where my program is crashing (segmentation fault) in intel machine and running fine on powerpc. I have found the cause of crash and the code snippet is below:</p>
  
  <pre><code>int function_a(int a)
  {
     int local_var = 1;
     int ret_var;
  
     ret_var = function_b(&amp;local_var);
  
  }
  
  int function_b (int* local_var_in_calld_fn)
  {
  
     while (some_condition)
     {
        *local_var_in_calld_fn = some_computed_value; /* Cause of crash */
        local_var_in_calld_fn++; 
     }
     return something;
  }
  </code></pre>
  
  <p>Some value is updated on an address which "may" be on stack and hence crashing.
  The code exactly does not crash at location, but when debugged in gdb crashes somewhere outside after coming out of this function on x86 machine.</p>
  
  <p>I am suspecting its corrupting the stack, but it is not crashing on powerpc. </p>
  
  <p>Thanks</p>