无用的分配Stackspace?

Odi*_*din 13 c x86 assembly stack

为什么这个函数在调用之前会分配比它需要的更多的堆栈空间gets()

echo:
  pushl  %ebp
  movl   %esp, %ebp
  pushl  %ebx
  leal   -8(%ebp), %ebx
  subl   $20,  %esp       <-- Why so much space?
  movl   %ebx, (%esp)
  call   gets
  ...
Run Code Online (Sandbox Code Playgroud)

相应的C代码:

void echo()
{
  char buf[4];
  gets(buf);
  puts(buf);
}
Run Code Online (Sandbox Code Playgroud)

为什么在缓冲区和gets的参数之间还有三个单词的额外空间?

堆栈http://s8.postimage.org/h2niz1kut/stack.png

hol*_*ium 11

计算机系统一书中有两句话."gcc遵循x86编程指南,该函数使用的总堆栈空间应为16字节的倍数." 和"包括保存的%ebp的4个字节和返回地址的4个字节",