Why does GCC allocate more space than necessary on the stack, beyond what's needed for alignment?

后端 未结 2 1342
忘掉有多难
忘掉有多难 2020-12-03 18:58

I\'m reading a textbook which shows assembly code based on C code:

C code:

void echo()
{
   char buf[8];
   otherFunction(buf);
}
         


        
2条回答
  •  长情又很酷
    2020-12-03 19:28

    AFAIK the stack must be 16 byte aligned for function calls but I have no clue as to why 24 bytes were allocated and not only 16.

    There are some questions about this on SO already. Why does GCC 6 assume data is 16-byte aligned?

    and on GCCs bugzilla https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838

提交回复
热议问题