c - how rsp is decremented in prologue on a X86-64 architecture -


i trying understand how functions called in c. when disassemble code (gcc - gdb; on linux i5-3320m) prologue of function toto:

void nop(){return ;}  void toto(int i, int j) { return; }  int main(int argc, char **argv) {   int = 1;   int* pt;   = 0; } 

i prologue:

   0x0000000000400523 <+0>: push   %rbp    0x0000000000400524 <+1>: mov    %rsp,%rbp    0x0000000000400527 <+4>: sub    $0x8,%rsp 

here don't understand why rsp decremented 8 not use local variable in toto. moreover, if use local variable:

void toto(int i, int j) {     int i=1     return; } 

i following prologue:

   0x0000000000400523 <+0>: push   %rbp    0x0000000000400524 <+1>: mov    %rsp,%rbp    0x0000000000400527 <+4>: sub    $0x18,%rsp 

and here don't understand why rsp decremented 0x18 (24 bytes). expect 16 bytes because have mysterious offset of 8, plus need 4 bytes int. architecture 64 bit, word in stack can't less 8 bytes 8+8 = 16.

the x86_64 abi requires upon entering function, %rsp multiple of 16. thus, after push %rbp, %rsp must subtracted value 0x8, 0x18, 0x28 etc.

update. sorry upvoted this, deceived you. can seen each push %rbp% paired call or callq gives 0x10 bytes, value subtracted %rsp must multiple of 0x10 well.

as first question, must compiling without optimization. optimization, functions collapse mere repz retq.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -