アセンブラでc関数を理解する方法を学ぼうとしています。「gcccode.c-m32-o code-S-fno-stack-protector」を使用して次のcプログラムをコンパイルしました
#include <stdio.h>
void function( int a, int b, int c )
{
char buffer1[5];
char buffer2[10];
}
void main()
{
function( 1, 2, 3 );
}
アセンブリの出力は次のとおりです。
.section __TEXT,__text,regular,pure_instructions
.globl _function
.align 4, 0x90
_function:
pushl %ebp
movl %esp, %ebp
subl $28, %esp
movl 16(%ebp), %eax
movl 12(%ebp), %ecx
movl 8(%ebp), %edx
movl %edx, -4(%ebp)
movl %ecx, -8(%ebp)
movl %eax, -12(%ebp)
addl $28, %esp
popl %ebp
ret
.globl _main
.align 4, 0x90
_main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl $1, (%esp)
movl $2, 4(%esp)
movl $3, 8(%esp)
call _function
addl $24, %esp
popl %ebp
ret
.subsections_via_symbols
int a、b、cを定義するオフセットが_mainと_functionで異なるため、espレジスタとebpレジスタを等しくすることはできません。ebpから4を引く行はどれですか?
ありがとう!