void main(){
int c;
c = function(1, 2);
}
int function(int a, int b){
char buf[10];
a = a+b;
return a;
}
アセンブリコード:
main:
08048394: push %ebp
08048395: mov %esp,%ebp
08048397: and $0xfffffff0,%esp
**0804839a: sub $0x20,%esp <-----------------------???????**
0804839d: movl $0x2,0x4(%esp)
080483a5: movl $0x1,(%esp)
080483ac: call 0x80483b7 <function>
080483b1: mov %eax,0x1c(%esp)
080483b5: leave
080483b6: ret
function:
080483b7: push %ebp
080483b8: mov %esp,%ebp
080483ba: sub $0x10,%esp
080483bd: mov 0xc(%ebp),%eax
080483c0: add %eax,0x8(%ebp)
080483c3: mov 0x8(%ebp),%eax
080483c6: leave
080483c7: ret
私は16バイトで整列されていることを知っています
が、main()でint c(=4 byte) + 1(4byte) + 2(4byte) in function(1 ,2)
ステートメントを呼び出します。
したがって、これの合計は12バイトです。しかし、メモリを調整することで、16バイトを検討します。
(sub 0x10, %esp)
なぜサブ0x20, %esp
?